Commit graph

16 commits

Author SHA1 Message Date
Kevin Eady
e41f70d72e
Add support for interpolated strings ("interstrings") (#369)
* Update grammar to support interpolated strings

* Struct initializers, case switchs are regular strings

* Initial stub for interpolated string in AST
This splits the previous STRING_LITERAL terminal into a production,
stringLiteral, to handle REGULAR_STRING terminal and interpolatedString
production.

* Change interpolated strings to expressions

* Fix mode handling in grammar

* Grammar fixes
- Fix mode handling in lexer
- Interpolated strings only have one expression

* Can successfully parse, stub compile interstrings
$"He {there + print("hello")}";

* Add formatting string to grammar

* Fix tests, and add test stubs

* Rename curleys to brace; better AST generation

* initial work interstring instruction

* Initial work on formatted string instruction: emit

* Formatted string instruction: execution

* Add simple formatted string test

* Add formatted string test src

* Review changes #1
- Rename `FormattedString` to `FormatExpression`
- Rename overloaded `try_to_format()` to `get_formatted()`

* Review changes part 2
- Rename `InterpolatedString` ast node to `InterpolateString`

* Review changes part 3
- Modify `ins_interpolate_string`

* Review changes part 4
- Remove unused formal parameter

* Add negative tests

* Spruce up positive tests

* Fix braces, escape chars inside interstring

* Fix, add tests for escaped char and double brace

* Address differences for new lines in tests

* Update Escript version

* Make empty expression an error

* Add documentation for interpolated strings

* Quick touchup on docs
2021-03-11 22:48:16 +01:00
Kevin Eady
ae96ecbf77
Remove OGC from EcompileMain, testsuites (#383)
* Remove OGC from escript testsuite

* Remove compiler options

* Remove Facility::Compiler

* Update docs and options in ecompile help usage

* Update core-changes, breaking-changes
2021-03-04 17:39:14 +01:00
Kevin Eady
44c864b917
Remove erroneous lexing productions (#371)
* Remove erroneous lexing productions

* Fix hex float literals

* Address review comments.
2021-02-27 23:54:07 +01:00
Eric Swanson
591eb37d04
New compiler: No longer reserved words: null, declare (#313)
* These are not reserved words:
  - null
  - declare

Fixes https://github.com/polserver/polserver/issues/309
2020-09-15 00:16:31 -07:00
Eric Swanson
d8ad58f64f
Update test suite for new compiler (#299)
* Update test suite:
- run test suite with both OG compiler and new compiler
- run compiler parity test against testsuite/escript
2020-09-11 01:38:39 -07:00
Eric Swanson
e42892fe7b Compiler v1 error messages in *.err1 files 2020-08-01 17:20:20 -07:00
Eric Swanson
13ba4ad940 Fix a bug in the legacy compiler .ecl output
The RSV_LOCAL offset should be the the local variable, not of the local variable within the block

Notice though, that the executor doesn't even use it.

There is more detail in the attached script.

listfile before:
/vagrant/testsuite/escript/bug/bug013-local-variable-index.src, Line 7
program foo()
var a;             // should be 0
0: decl local #0
1: #
if ( a )
2: local #0
3: if false goto 17
var b;         // should be 1    actually emitted 0
4: decl local #0
5: #
var c;         // should be 2    actually emitted 1
6: decl local #1
7: #
if ( b )
8: local #1
9: if false goto 16
var d;     // should be 3    actually emitted 0
10: decl local #0
11: #
print(d);
12: local #3
13: Func(1,0): Print
14: #
15: leave block(1)
16: leave block(2)
17: leave block(1)
18: progend

listfile after:
/vagrant/testsuite/escript/bug/bug013-local-variable-index.src, Line 7
program foo()
var a;             // should be 0
0: decl local #0
1: #
if ( a )
2: local #0
3: if false goto 17
var b;         // should be 1    actually emitted 0
4: decl local #1
5: #
var c;         // should be 2    actually emitted 1
6: decl local #2
7: #
if ( b )
8: local #1
9: if false goto 16
var d;     // should be 3    actually emitted 0
10: decl local #3
11: #
print(d);
12: local #3
13: Func(1,0): Print
14: #
15: leave block(1)
16: leave block(2)
17: leave block(1)
18: progend
2020-07-29 00:05:52 -07:00
turleypol
07f324040f
Merge pull request #149 from polserver/syz-fix-em-param-name-clash
Fix compiler bug with user function names that match module function argument names
2020-06-16 21:29:03 +02:00
Eric Swanson
e7733ccf19 Fix compiler bug: user functions should be able to have the same name as module function parameter names 2020-06-15 22:27:57 -07:00
Eric Swanson
fd6b722eaf Fix optimization error: will sometimes patch an offset of the wrong instruction when
rolling back an if statement branch.
2020-06-14 03:31:03 -07:00
Eric Swanson
252a4947ce Add bug010 - optimizer bug with if statements 2020-06-13 19:10:33 -07:00
Eric Swanson
51129732d1 Make it a compilation error to hit EOF while expecting an expression terminator (usually semicolon). 2020-06-10 22:14:31 -07:00
turleypol
e6f59a69a9 removed instructions testscript files they are not used
removed appveyor xml testresult (I'm to dumb)
2018-10-31 12:09:31 +01:00
Gabriele Tozzi
861ff58d1d Fixed: Minor bug in ecompile allowing Double in the form "2d4".
These were incorrectly interpreted as "2e4", meaning 20000 and
leading to confusion with dice rolls. The compiler now issues an
error instead.
Added related test cases.
2016-01-22 00:16:39 +01:00
Gabriele Tozzi
e085b218f6 Unit tests: full revision, now all run correctly
- Added missing ones
- Reviewed obsoleted ones
- Disabled/deleted unnecessary ones
- Added support for compile error checking
- Added support for run error checking
2015-12-19 05:31:23 +01:00
Gabriele Tozzi
0efeb4d379 Unit Tests: putting some orde rin escript unit tests 2015-12-19 02:31:08 +01:00