Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bddaf86
Compiler.Backend.downloadUrl now takes in the version to generate an …
robinheghan Sep 27, 2025
bd7e2fc
Setup boilerplate for parser tests
robinheghan Sep 27, 2025
38a2d9d
Implement parsing of decimal integers
robinheghan Sep 27, 2025
c34b4f1
Implement parsing of floats
robinheghan Sep 27, 2025
ced40c4
Refactor in preparation for hex numbers
robinheghan Sep 27, 2025
ea15a1e
Hex numbers now implemented
robinheghan Sep 29, 2025
4456e4d
Fix Makefile in integration-test, which didn't cache-invalidate when …
robinheghan Sep 29, 2025
59c30a6
Initial implementation of char parser
robinheghan Oct 2, 2025
6e419cc
Implement escape codes in character parser
robinheghan Oct 5, 2025
05edc9b
Implement string parser. Unicode values with surrogate pairs seems to…
robinheghan Oct 5, 2025
0919775
Update dependencies to fix parse error
robinheghan Oct 13, 2025
fcf6eab
Start work on variable name parsing
robinheghan Oct 13, 2025
a6e8428
Full implementation of variable parser
robinheghan Oct 19, 2025
05902ea
Started implementing multi-line strings
robinheghan Oct 19, 2025
ed97659
Refuse to parse reserved words
robinheghan Oct 19, 2025
1b554ce
Finish implementation of multi-line strings
robinheghan Oct 26, 2025
4af5351
Add AST for expressions, and setup boilerplate to parse it
robinheghan Oct 31, 2025
221747e
Parse primitive expressions
robinheghan Oct 31, 2025
e98c813
Parse accessors
robinheghan Oct 31, 2025
9e9db6a
Parse arrays
robinheghan Oct 31, 2025
58889ae
Parse record expressions
robinheghan Oct 31, 2025
3e6c792
Fix integration tests.
robinheghan Oct 31, 2025
ba32d2a
Parse if-expressions
robinheghan Nov 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"lockfile_version": "1",
"packages": {
"github:NixOS/nixpkgs/nixpkgs-unstable": {
"last_modified": "2025-09-25T01:21:52Z",
"resolved": "github:NixOS/nixpkgs/e57b3b16ad8758fd681511a078f35c416a8cc939?lastModified=1758763312&narHash=sha256-puBMviZhYlqOdUUgEmMVJpXqC%2FToEqSvkyZ30qQ09xM%3D"
"last_modified": "2025-10-12T08:13:11Z",
"resolved": "github:NixOS/nixpkgs/832e3b6db48508ae436c2c7bfc0cf914eac6938e?lastModified=1760256791&narHash=sha256-uTpzDHRASEDeFUuToWSQ46Re8beXyG9dx4W36FQa0%2Fc%3D"
},
"gren@0.6": {
"last_modified": "2025-09-18T16:33:27Z",
Expand Down
14 changes: 11 additions & 3 deletions gren.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "BSD-3-Clause",
"version": "3.0.7",
"exposed-modules": [
"AST.Source",
"CLI.Parser",
"CLI.PrettyPrinter",
"Compiler.Backend",
Expand All @@ -17,13 +18,20 @@
"Compiler.Paths",
"Compiler.License",
"FileSystem.Lock",
"Parse.Expression",
"Parse.Number",
"Parse.String",
"Parse.Space",
"Parse.Variable",
"SemanticVersion",
"SemanticVersionRange",
"String.EditDistance"
"String.EditDistance",
"SourcePosition"
],
"gren-version": "0.6.0 <= v < 0.7.0",
"dependencies": {
"gren-lang/core": "7.1.0 <= v < 8.0.0",
"gren-lang/node": "6.1.0 <= v < 7.0.0"
"gren-lang/core": "7.2.1 <= v < 8.0.0",
"gren-lang/node": "6.1.0 <= v < 7.0.0",
"gren-lang/parser": "6.2.0 <= v < 7.0.0"
}
}
Binary file removed gren_packages/gren_lang_core__7_1_0.pkg.gz
Binary file not shown.
Binary file added gren_packages/gren_lang_core__7_2_1.pkg.gz
Binary file not shown.
Binary file added gren_packages/gren_lang_parser__6_2_0.pkg.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules: package.json package-lock.json
npm ci

bin/app: Makefile gren.json node_modules
bin/app: Makefile gren.json node_modules ../gren.json ../src/**/*.gren
gren make Main --output=bin/app
chmod +x bin/app

Expand Down
5 changes: 3 additions & 2 deletions integration-tests/gren.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"gren-version": "0.6.3",
"dependencies": {
"direct": {
"gren-lang/core": "7.1.0",
"gren-lang/core": "7.2.1",
"gren-lang/node": "6.1.0",
"gren-lang/compiler-node": "local:.."
},
"indirect": {
"gren-lang/url": "6.0.0"
"gren-lang/url": "6.0.0",
"gren-lang/parser": "6.2.0"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
202 changes: 202 additions & 0 deletions src/AST/Source.gren
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
module AST.Source exposing
( Expression
, Expression_ (..)
, VarType (..)
, BinopsSegment
, IfBranch
, WhenBranch
, RecordField
, Def (..)
, Pattern
, Pattern_ (..)
, PRecordField
, PRecordField_
, Type
, Type_
, TRecordField
)

import SourcePosition
import Parse.Number as Number


type alias Expression =
SourcePosition.Located Expression_


type Expression_
= CharLiteral Char
| StringLiteral String
| NumberLiteral Number.Outcome
| Var
{ varType : VarType
, name : String
}
| VarQual
{ varType : VarType
, qualifier : String
, name : String
}
| ArrayLiteral (Array Expression)
| Record (Array RecordField)
| Update
{ record : Expression
, newValues : Array RecordField
}
| Operator String
| Negate Expression
| Binops
{ segments : Array BinopsSegment
, finalExpression : Expression
}
| Lambda
{ patterns : Array Pattern
, body : Expression
}
| Call
{ fn : Expression
, args : Array Expression
}
| Let
{ defs : Array (SourcePosition.Located Def)
, body : Expression
}
| If
{ branches : Array IfBranch
, elseBranch : Expression
}
| When
{ expression : Expression
, branches : Array WhenBranch
}
| Accessor String
| Access
{ expression : Expression
, accessor : String
}
| Parens Expression


type VarType
= LowVar
| CapVar


type alias BinopsSegment =
{ leadingExpression : Expression
, operatorName : SourcePosition.Located String
}


type alias IfBranch =
{ test : Expression
, body : Expression
}


type alias WhenBranch =
{ pattern : Pattern
, body : Expression
}


type alias RecordField =
{ field : SourcePosition.Located String
, value : Expression
}


-- DEFINITIONS


type Def
= Define
{ name : SourcePosition.Located String
, args : Array Pattern
, body : Expression
, typeSignature : Maybe Type
}
| Destruct
{ pattern : Pattern
, expression : Expression
}


-- PATTERN


type alias Pattern
= SourcePosition.Located Pattern_


type Pattern_
= PAnything String
| PVar String
| PRecord (Array PRecordField)
| PAlias
{ pattern : Pattern
, name : SourcePosition.Located String
}
| PCtor
{ var : SourcePosition.Located String
, associatedData : Maybe Pattern
}
| PCtorQual
{ varRegion : SourcePosition.Region
, qualifier : String
, name : String
, associatedData : Maybe Pattern
}
| PArray (Array Pattern)
| PChr Char
| PStr String
| PInt
{ value : Int
, isHex : Bool
}


type alias PRecordField
= SourcePosition.Located PRecordField_


type alias PRecordField_ =
{ field : SourcePosition.Located String
, pattern : Pattern
}


-- TYPE


type alias Type =
SourcePosition.Located Type_


type Type_
= TLambda
{ from : Type
, to : Type
}
| TVar String
| TType
{ name : SourcePosition.Located String
, args : Array Type
}
| TTypeQual
{ varRegion : SourcePosition.Region
, qualifier : String
, name : String
, args : Array Type
}
| TRecord
{ fields : Array TRecordField
, extending : Maybe (SourcePosition.Located String)
}
| TParens Type


type alias TRecordField =
{ field : SourcePosition.Located String
, signature : Type
}
23 changes: 4 additions & 19 deletions src/Compiler/Backend.gren
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Compiler.Backend exposing
( version
--
, Command(..)
( Command(..)
, ReplFlags
, MakeFlags
, MakeOutput(..)
Expand Down Expand Up @@ -47,19 +45,6 @@ import HttpClient
import Process


{-| Version of the compiler blob. This might not match the version of the Gren compiler as a whole,
as the Haskell- and Gren-parts are versioned seperatly.
-}
version : String
version =
-- TODO: Let's get rid of this.
-- We're already planning to keep backend and frontend releases in sync moving forward
"0.6.3"


-- Binary


{-| Type used to signal that the given platform isn't supported. Meaning that there doesn't exist
a pre-built compiler blob.
-}
Expand All @@ -70,8 +55,8 @@ type UnsupportedPlatform
{-| Construct a URL from which you can download a compiler blob compatible with the given
platform and cpu architecture.
-}
downloadUrl : Node.Platform -> Node.CpuArchitecture -> Result UnsupportedPlatform String
downloadUrl platform cpuArch =
downloadUrl : SemanticVersion -> Node.Platform -> Node.CpuArchitecture -> Result UnsupportedPlatform String
downloadUrl version platform cpuArch =
let
maybeFilename =
when { platform = platform, cpuArch = cpuArch } is
Expand All @@ -95,7 +80,7 @@ downloadUrl platform cpuArch =
Ok <|
String.join "/"
[ "https://github.com/gren-lang/compiler/releases/download"
, version
, SemanticVersion.toString version
, filename
]

Expand Down
Loading