Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2 Compiler Rewrite #2555

Merged
merged 140 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
9da154c
Initial attempt
Vurv78 Dec 8, 2022
73eac2a
Merge remote-tracking branch 'upstream/master' into parser-rewrite
Vurv78 Dec 8, 2022
3628a23
Sync
Vurv78 Dec 16, 2022
b09c870
Sync
Vurv78 Dec 17, 2022
0ed076c
First functional prototype
Vurv78 Dec 19, 2022
8b2561f
More changes
Vurv78 Dec 20, 2022
db33d26
Pass test suite
Vurv78 Dec 22, 2022
e5b090b
Reimplement prf checks & Variadic params
Vurv78 Feb 5, 2023
9de2edb
Fix methodcall and legacy case
Vurv78 Feb 24, 2023
c3c05f0
Many changes
Vurv78 Feb 24, 2023
50c86dd
Fix runtime error detection
Vurv78 Feb 24, 2023
e59a274
Fix e2test runtime errors
Vurv78 Feb 24, 2023
a8f087d
Too many changes
Vurv78 Mar 5, 2023
e53d960
Runtime changes
Vurv78 Mar 5, 2023
2447d68
Reimplement legacy op support, Runtime changes
Vurv78 Mar 6, 2023
d7e1a11
Fixes
Vurv78 Mar 7, 2023
f3796d9
Add variadic unit test
Vurv78 Mar 7, 2023
8e946cf
More fixes
Vurv78 Mar 7, 2023
57ea52a
Parity (Awfulness)
Vurv78 Mar 9, 2023
6eb26c0
Fix local declaration and increment/decrement
Vurv78 Mar 18, 2023
fd1153c
Fix case of indexing breaking parsing
Vurv78 Mar 21, 2023
d23af00
Multiple fixes
Vurv78 Mar 21, 2023
d1d457e
Rewrite foreach
Vurv78 Mar 21, 2023
7e991ee
Support data indexing clks
Vurv78 Mar 21, 2023
2021caf
Switch case support
Vurv78 Mar 21, 2023
c6e004d
Fix a unit test
Vurv78 Mar 21, 2023
5a40acd
Implement unary wire operators
Vurv78 Mar 21, 2023
6c3e319
Kill `wire_expression2_delta`
Vurv78 Mar 21, 2023
29ba930
Fix strict and 2420 unit tests
Vurv78 Mar 21, 2023
e7660f4
Fix function scoping at compile time
Vurv78 Mar 21, 2023
f7069e0
Fix methodcall passing function for method
Vurv78 Mar 21, 2023
c5e1578
Fix indexing assignment parsing and compilation
Vurv78 Mar 22, 2023
6834a5f
Ops changes + operator_is -> "is"
Vurv78 Mar 22, 2023
c2b6fa1
Reimplement unused variable warn + Discards
Vurv78 Mar 22, 2023
a7d505b
Fix cases where variables aren't marked as used
Vurv78 Mar 22, 2023
451f4c2
Fix "This" unused trace
Vurv78 Mar 23, 2023
47ee9d1
Fix fastest case condition with meta type
Vurv78 Mar 23, 2023
5462836
Fix operators not marked as nonlegacy
Vurv78 Mar 23, 2023
fa516e3
Hopefully finally fix assignment parsing
Vurv78 Apr 1, 2023
7f8a70a
Fix parser's `Assert` error
Vurv78 Apr 1, 2023
d3a3440
Mark indexing assignment variables as used
Vurv78 Apr 1, 2023
c59cc6b
Rewrite vector operators
Vurv78 Apr 1, 2023
518fb46
Allow variable shadowing & Fix -> operator
Vurv78 Apr 1, 2023
e5ea119
Fix error compiling void recursion
Vurv78 Apr 2, 2023
28ccb8d
Simplify include code
Vurv78 Apr 2, 2023
288c924
Fix include scoping
Vurv78 Apr 2, 2023
bf176d3
Fix some scopings
Vurv78 Apr 2, 2023
cf34e00
Check for nil in switch
Vurv78 Apr 2, 2023
5c8cc76
Fix userfunction vararg check
Vurv78 Apr 2, 2023
ef6ef38
Rewrite extpp
Vurv78 Apr 2, 2023
9ffad07
Actually define the parameters
Vurv78 Apr 2, 2023
b93359d
Fix extpp operator implementation
Vurv78 Apr 2, 2023
28b70ca
Fix changed() functions
Vurv78 Apr 2, 2023
8bb82ff
Discard optimizations
Vurv78 Apr 2, 2023
c37a307
Fully implement stringcalls
Vurv78 Apr 2, 2023
4d1fdc5
Some fixes
Vurv78 Apr 2, 2023
f784d02
Add traces to quota and internal errors
Vurv78 Apr 2, 2023
2ff56f1
Reimplement some warnings & Tidy code
Vurv78 Apr 2, 2023
0fc982b
Initialize variable on assignment
Vurv78 Apr 2, 2023
42b7527
Don't trigger non-table types
Vurv78 Apr 2, 2023
e438e9b
Missed a spot
Vurv78 Apr 2, 2023
c7d5fed
Fix wirelink indexget
Vurv78 Apr 3, 2023
41ee00e
Fix preprocessor errors
Vurv78 Apr 5, 2023
a9fca5c
Fix sign and include variables
Vurv78 Apr 5, 2023
779284f
Rework extpp some more
Vurv78 Apr 5, 2023
7ad7090
Merge remote-tracking branch 'upstream/master' into e2-compiler-rewrite
Vurv78 Apr 5, 2023
5c4ff83
Remove E2Lib.Env.Types
Vurv78 Apr 5, 2023
fa2d4b3
Remove support for single quat/complex literals
Vurv78 Apr 5, 2023
3a5aec2
Fix syntax error
Vurv78 Apr 5, 2023
8c47365
Fixes & New tests
Vurv78 Apr 6, 2023
599fcb6
Fix void return and add more function test cases
Vurv78 Apr 6, 2023
fac022a
Parity and a lot more tests
Vurv78 Apr 6, 2023
0d60c56
Fixes & Cleanup
Vurv78 Apr 7, 2023
99e6b23
Fixes, parity & test cases
Vurv78 Apr 7, 2023
95533c1
Fixes & Parity
Vurv78 Apr 22, 2023
a89aab4
Fix vararg issues
Vurv78 Jun 3, 2023
261a4d7
`types` -> `typeids`
Vurv78 Jun 3, 2023
a22e995
Fix exit() and reset() not resetting scope
Vurv78 Jun 6, 2023
6c90fe6
Fix events not compiling, Remove some legacy support
Vurv78 Jun 7, 2023
82c3d32
Revert "is" operators now using registerOperator
Vurv78 Jun 7, 2023
6bd1608
Merge remote-tracking branch 'upstream/master' into e2-compiler-rewrite
Vurv78 Jun 7, 2023
c64f129
Proper multiline traces
Vurv78 Jun 21, 2023
2b8f300
Merge remote-tracking branch 'upstream/master' into e2-compiler-rewrite
Vurv78 Jun 21, 2023
219b693
Fix incorrect stitching
Vurv78 Jun 21, 2023
8fdd9dc
Ordered table keyvalue creation
Vurv78 Jun 21, 2023
89fdf8f
Merge remote-tracking branch 'upstream/master' into e2-compiler-rewrite
Vurv78 Jun 22, 2023
60933de
Fix delta ($) and deprecated wirelink index method
Vurv78 Jun 22, 2023
7b27a69
Fix old dupes with dupevars missed in #2462
Vurv78 Jun 22, 2023
140ac25
Add variadic string call support & Legacy support
Vurv78 Jun 24, 2023
4c96be8
Cleaner E2Lib.compileScript
Vurv78 Jun 24, 2023
56ff230
Remove unused `run` param
Vurv78 Jun 24, 2023
7864a5f
Slight tweaks
Vurv78 Jun 25, 2023
ace0ec7
Fix parser trace error
Vurv78 Jun 25, 2023
f4b5ae5
Merge branch 'master' into e2-compiler-rewrite
Vurv78 Jun 27, 2023
26cd3fd
Remove assignment operator
Vurv78 Jun 27, 2023
03d5a5c
Merge branch 'master' into e2-compiler-rewrite
Vurv78 Jul 9, 2023
a357524
Merge branch 'master' into e2-compiler-rewrite
Vurv78 Jul 12, 2023
9c4ae18
Fix assignment not reusing expression
Vurv78 Jul 13, 2023
d279220
String library fixes
Vurv78 Jul 13, 2023
c0741eb
Add stringcall array restriction edge case
Vurv78 Jul 13, 2023
73da11d
Fix removed operators not preprocessing
Vurv78 Jul 13, 2023
94253ef
Enforce new void representation
Vurv78 Jul 13, 2023
248d9ef
Variadic user function stringcall support
Vurv78 Jul 13, 2023
91408e9
Add stringcall method function test
Vurv78 Jul 13, 2023
c966eb7
Rearrange tests & Add library tests
Vurv78 Jul 14, 2023
84d0788
Temporary overriding return patch
Vurv78 Jul 17, 2023
0ed275f
Fix operator= causing errors
Vurv78 Jul 17, 2023
5ee9497
Proper function override fix
Vurv78 Jul 17, 2023
91fed76
Fix incorrect error message on event error
Vurv78 Jul 17, 2023
32f7aad
Fix for loop continue bleeding
Vurv78 Jul 17, 2023
7f7d9d7
Fix foreach not having break return and continue implemented
Vurv78 Jul 17, 2023
40ebf06
Fix user function overriding, add override optimization
Vurv78 Jul 17, 2023
2987d56
Fix switch case early break
Vurv78 Jul 18, 2023
90c82c4
Fix nil argument stopping udf arguments
Vurv78 Jul 18, 2023
f330fc7
Reimplement runtime undefined function error
Vurv78 Jul 18, 2023
0f43439
Fix keyvalue calls not accepting identifiers
Vurv78 Jul 27, 2023
aa1bd4f
Fix dupes
Vurv78 Jul 27, 2023
150e6c4
Fix while loop continue
Vurv78 Jul 29, 2023
dbbd725
Merge branch 'master' into e2-compiler-rewrite
Vurv78 Aug 6, 2023
44125d3
Add stackdepth to runtimecontext builder
Vurv78 Aug 6, 2023
701ee4a
notify for syntax errors again
Fasteroid Aug 13, 2023
2402d9b
Merge pull request #10 from Fasteroid/issues/9
Vurv78 Aug 13, 2023
d0e828b
Fix switch fallthrough running same case twice
Vurv78 Aug 25, 2023
f9d1b39
Merge branch 'master' into e2-compiler-rewrite
Vurv78 Aug 27, 2023
fe6649e
Add default == operator in case it is absent
Vurv78 Sep 10, 2023
f0aa7c6
Don't store scope in VarData
Vurv78 Sep 10, 2023
7e53a50
Rewrite compound operator, decrement/increment operators
Vurv78 Sep 11, 2023
0462fdc
Remove redundant "is" return enforcement
Vurv78 Sep 11, 2023
387ddd8
ExtPP tweaks
Vurv78 Sep 11, 2023
cb6bcd0
Highlight and autocomplete user defined functions
Vurv78 Sep 11, 2023
3550624
Fix string and byte foreach, add tests
Vurv78 Sep 11, 2023
a18f50a
Add explicit catch error typing
Vurv78 Sep 11, 2023
3a9fba2
Change nontable foreach warning message
Vurv78 Sep 11, 2023
fd341de
Fix ExtPP generating trailing whitespace for aliases
Vurv78 Sep 11, 2023
c565100
Split parsing test into several files
Vurv78 Sep 11, 2023
55577f5
Deprecate E2Lib.raiseException
Vurv78 Sep 12, 2023
0465ab9
Fix precedence of certain operators
Vurv78 Sep 13, 2023
60c1811
Remove preprocessor attribution
Vurv78 Sep 13, 2023
7390fcf
Optimize runtime scoping
Vurv78 Sep 13, 2023
0b99039
Fix preprocessor error causing internal error
Vurv78 Sep 15, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## SHOULD_FAIL:COMPILE

# Cannot hold an array in an array

local A = array(array())
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## SHOULD_FAIL:COMPILE

# Cannot override existing function with function that has different return type

function test() {

}

function number test() {
return 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## SHOULD_PASS:COMPILE

# Can override existing function with function that has different return type

function test() {
}

function test() {
print("zoo wee mama")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## SHOULD_FAIL:COMPILE

# Cannot use void return as an expression

local E = print()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_FAIL:COMPILE

# Cannot use void return as an expression

function void test() {}

local E = test()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_FAIL:COMPILE

# Cannot call array variadic function with array argument.

function arrayVariadic(N:number, ...X:array) {}

arrayVariadic(1, array())
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_FAIL:COMPILE

# Cannot call array variadic method with array argument.

function number:arrayVariadic(N:number, ...X:array) {}

1:arrayVariadic(1, array(1, 2, 3))
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## SHOULD_FAIL:COMPILE

# Can't override existing function with variadic
function print(...A:array) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## SHOULD_PASS:COMPILE

# You can however override if there is a parameter beforehand.
function print(N:number, ...A:array) {}
7 changes: 7 additions & 0 deletions data/expression2/tests/compiler/parser/array.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_PASS:COMPILE

array()

array(1, 2, 3)

array(2 = 4, 5 = 7)
14 changes: 14 additions & 0 deletions data/expression2/tests/compiler/parser/assign.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## SHOULD_PASS:COMPILE

Var = 5

local OtherVar = 2

A=B=C=5

A++
A--
A += 1
A -= 1
A *= 1
A /= 1
6 changes: 6 additions & 0 deletions data/expression2/tests/compiler/parser/call.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## SHOULD_PASS:COMPILE

min(1, 2)
print("foo", 2)

array():count()
4 changes: 4 additions & 0 deletions data/expression2/tests/compiler/parser/constants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## SHOULD_PASS:COMPILE

_PI
_E
4 changes: 4 additions & 0 deletions data/expression2/tests/compiler/parser/events.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## SHOULD_PASS:COMPILE

event tick() {}
event chat(_:entity, _:string, _) {}
9 changes: 9 additions & 0 deletions data/expression2/tests/compiler/parser/for.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## SHOULD_PASS:COMPILE

for (B = 1, 2) {
break
}

for (B = 1, 2, 3) { continue }

for (_ = 1, 5) {}
11 changes: 11 additions & 0 deletions data/expression2/tests/compiler/parser/foreach.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## SHOULD_PASS:COMPILE

foreach(K,V:number=array(1, 2, 3)) { break }
foreach (K:number,V:number=array(1, 2, 3)) { continue }

foreach (K: number, V: number = array(1, 2, 3)) {
continue
}

foreach (K:number, _:entity = table()) {}
foreach (_, _:entity = table()) {}
18 changes: 18 additions & 0 deletions data/expression2/tests/compiler/parser/functions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## SHOULD_PASS:COMPILE

function unimplemented(_) {}
unimplemented(5)

function f() {}
function r() { return }

function number test() { return 55 }
function entity:test() { return void }
function number test(X, Y: vector) { return X }
function number test([X Y]) { return X + Y }
function number test([X Y]: number) { return X + Y }

function number entity:test(...Variadic:array) {
Expression = ( test() + 2 )
return Expression
}
7 changes: 7 additions & 0 deletions data/expression2/tests/compiler/parser/if.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_PASS:COMPILE

if (1) {}

if (1) {} elseif (2) {}

if (1) {} elseif (2) {} else {}
6 changes: 6 additions & 0 deletions data/expression2/tests/compiler/parser/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## SHOULD_PASS:COMPILE

array()[1, number]

A = array()
A[1, number] = 5
9 changes: 9 additions & 0 deletions data/expression2/tests/compiler/parser/io.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## SHOULD_PASS:COMPILE

@inputs In
@outputs Out

~In
$In
->In
->Out
30 changes: 30 additions & 0 deletions data/expression2/tests/compiler/parser/numbers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## SHOULD_PASS:COMPILE

# Hexadecimal
0x2042
0xDEADBEEF
0xdeadbeef

# Binary
0b00111001
0b0011111

# Decimal
2432.2352
2193.23e2
-2139.123e63

# Integer
1
-512

# Quaternion literals
2j
4.4k
1k
1j

# Complex literals
3i
2.7i
1i
5 changes: 5 additions & 0 deletions data/expression2/tests/compiler/parser/ops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## SHOULD_PASS:COMPILE

!(+(-(0 >> 1 << 2 * 3 + 4 - 5 / 6 % 7 && 8 || 9 != 10 == 11 <= 12 >= 13 ^^ 14)))

0 | 1 & 2 != 3 == 4
12 changes: 12 additions & 0 deletions data/expression2/tests/compiler/parser/strings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## SHOULD_PASS:COMPILE

"foo bar"

"foo\nbar"

"\n\t\r\a\v\b\\"
"\""

"
Multiline
"
13 changes: 13 additions & 0 deletions data/expression2/tests/compiler/parser/switch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## SHOULD_PASS:COMPILE

switch (2) {
case 1,
case Var,
default,
}

switch (3) {
case 1, break,
case 2,
default, break
}
9 changes: 9 additions & 0 deletions data/expression2/tests/compiler/parser/table.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## SHOULD_PASS:COMPILE

table(1, 2, 3)

N = 5
table(N = 1, 2 = 2)

K = ""
table(K = 5, "" = 5)
7 changes: 7 additions & 0 deletions data/expression2/tests/compiler/parser/ternary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_PASS:COMPILE

1 ? 2 : 3
"1" ? "2" : "3"

5 ?: 3
"a" ?: "b"
7 changes: 7 additions & 0 deletions data/expression2/tests/compiler/parser/try.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## SHOULD_PASS:COMPILE

try {} catch (E) {}
try {} catch (Err:string) {}

try {} catch(_) {}
try {} catch(_:string) {}
10 changes: 10 additions & 0 deletions data/expression2/tests/compiler/parser/while.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## SHOULD_PASS:COMPILE

while (1) { A = 0 }

while (1) { break }
while (1) { continue }

do { A = 0 } while (1)
do { break } while (2)
do { continue } while (3)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## SHOULD_FAIL:COMPILE

#error Hello, world!
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## SHOULD_PASS:COMPILE

#ifdef print(...)
#else
#error Uhh
#endif
10 changes: 10 additions & 0 deletions data/expression2/tests/compiler/preprocessor/commands/ifndef.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## SHOULD_PASS:COMPILE

#ifndef print(...)
#error Uhh
#endif

#ifndef print(...)
#error Uhh 2
#else
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## SHOULD_PASS:COMPILE

#warning XYZ
13 changes: 13 additions & 0 deletions data/expression2/tests/compiler/preprocessor/comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## SHOULD_PASS:COMPILE

#[
Hello, world!
]#

#[]#
#[ content ]#

#
#

#
10 changes: 10 additions & 0 deletions data/expression2/tests/compiler/preprocessor/directives.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## SHOULD_PASS:COMPILE

@name Test
@persist [X Y]:number Z:number W
@inputs [J K]:number L:number M
@outputs [A B]:number C:number D
@trigger X Y
@autoupdate
@model f
@strict
Loading
Loading