Skip to content

Commit

Permalink
String interpolation align and format support
Browse files Browse the repository at this point in the history
Enhancements:
- Support alignment and format specifiers for interpolated expressions in string literals (#1071)
- Improved error recovery and reporting for incomplete string interpolations
  • Loading branch information
degory committed Feb 27, 2024
1 parent 88c4e77 commit da3dcec
Show file tree
Hide file tree
Showing 99 changed files with 786 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"ghul.compiler": {
"version": "0.8.1",
"version": "0.8.2",
"commands": [
"ghul-compiler"
]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.8.2-alpha.127</Version>
<Version>0.8.3-alpha.56</Version>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test.ghul: 6,5..7,1: error: newline in string literal
test.ghul: 6,17..6,18: error: newline in string literal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
entry() is
let x = 10;
let y = 20;

"interpolate
si

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 8,5..8,6: error: newline in string literal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

entry() is
let x = 10;
let y = 20;

"interpolate {x,y:G} interpolate {x,1234: ABCDEF } blah blah";

"
si
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,19..7,33: error: in primary expression: expected (, [, cast, char literal, false, float literal, identifier, if, int literal, isa, new, null, self, string literal, super, true, typeof or { but found } interpolate
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

entry() is
let x = 10;
let y = 20;

// FIXME we need better error recovery here
"interpolate {} interpolate";
si
Empty file.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test.ghul: 7,19..8,1: error: newline in string literal
test.ghul: 7,31..7,32: error: newline in string literal
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ entry() is
let y = 20;

// FIXME we need better error recovery here
"interpolate {}
"interpolate {} interpolate
si

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,1..7,3: error: in primary expression: expected (, [, cast, char literal, false, float literal, identifier, if, int literal, isa, new, null, self, string literal, super, true, typeof or { but found si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

entry() is
let x = 10;
let y = 20;

"interpolate {x,y:G} interpolate {
si
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,1..7,3: error: syntax error: expected } but found si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,19..7,20: error: newline in string literal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

entry() is
let x = 10;
let y = 20;

// FIXME we need better error recovery here
"interpolate {}
si
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

entry() is
let x = 10;
let y = 20;

"interpolate {x,y:G} interpolate {x
si
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,1..7,3: error: in primary expression: expected (, [, cast, char literal, false, float literal, identifier, if, int literal, isa, new, null, self, string literal, super, true, typeof or { but found si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

entry() is
let x = 10;
let y = 20;

"interpolate {x,y:G} interpolate {x,
si
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 7,1..7,3: error: syntax error: expected } but found si
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compiler": "dotnet ../../../publish/ghul.dll",
"source": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--type-check
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

entry() is
let x = 10;
let y = 20;

"interpolate {x,y:G} interpolate {x,1234
si
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run test",
"command": "dotnet ghul-test \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Capture test expectation",
"command": "../../../tasks/capture.sh \"${workspaceFolder}\"",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ghul: 6,53..6,54: error: newline in interpolation format string
Loading

0 comments on commit da3dcec

Please sign in to comment.