This replaces the old parser with a pest-derived parser. It currently implements all text-format functionality required for the tests to pass, meaning that there may be syntax that the old parser supported that the new one doesn't (I'm not sure if there is, actually). The goal is to extend this parser to support some new functionality required for sonatina to be a useful evm backend ("objects", contract constructor functions, etc), but that'll happen in future PRs.
Some minimal error checking is performed (duplicate values definitions, referring to undefined identifiers, etc).
I also made some minor syntax changes:
function bodies are wrapped in braces
the i1 "true" value is now 1, instead of -1
Note that there are a couple small changes to the optimization passes, to make them work with alias values, though I made no attempt to ensure they function correctly in all situations involving alias values, just the particular situations that arose during testing. (I haven't thought about a more general solution to this problem, but perhaps we could discuss this.) The parser introduces an alias when a value is used before it's defined (in the textual form of the program, not the actual execution flow of course). For example:
In this case, the name v1 will first be marked as undefined, and given a new value id with a dummy value, say Value(5). When the definition of v1 is reached, we create a new value id for the definition, say Value(6), associate the name v1 with Value(6), and change Value(5) to be an alias of Value(6). (Note that unlike in the old parser, the name "v1" isn't guaranteed to be associated with ir::Value(0))
TODO:
[x] type defs
[x] fix number parsing failure in interpreter test
[x] move value_names bimap
[ ] filecheck fork with regex change and failure print fix (I'll do this later)
[x] xxxes
[x] discuss value alias usage, fixes in optimizations
This replaces the old parser with a pest-derived parser. It currently implements all text-format functionality required for the tests to pass, meaning that there may be syntax that the old parser supported that the new one doesn't (I'm not sure if there is, actually). The goal is to extend this parser to support some new functionality required for sonatina to be a useful evm backend ("objects", contract constructor functions, etc), but that'll happen in future PRs.
Some minimal error checking is performed (duplicate values definitions, referring to undefined identifiers, etc).
I also made some minor syntax changes:
1
, instead of-1
Note that there are a couple small changes to the optimization passes, to make them work with alias values, though I made no attempt to ensure they function correctly in all situations involving alias values, just the particular situations that arose during testing. (I haven't thought about a more general solution to this problem, but perhaps we could discuss this.) The parser introduces an alias when a value is used before it's defined (in the textual form of the program, not the actual execution flow of course). For example:
In this case, the name
v1
will first be marked as undefined, and given a new value id with a dummy value, sayValue(5)
. When the definition ofv1
is reached, we create a new value id for the definition, sayValue(6)
, associate the namev1
withValue(6)
, and changeValue(5)
to be an alias ofValue(6)
. (Note that unlike in the old parser, the name "v1" isn't guaranteed to be associated withir::Value(0)
)TODO:
filecheck fork with regex change and failure print fix(I'll do this later)