mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 08:29:25 +00:00
improved parsing of "not in" operator, and [] array signature (allow space)
This commit is contained in:
parent
e83d0ee820
commit
fff0d741c3
@ -884,7 +884,7 @@ class TestProg8Parser: FunSpec( {
|
||||
main {
|
||||
sub start() {
|
||||
str string = "hello"
|
||||
ubyte[] array = [1,2,3,4]
|
||||
ubyte[ ] array = [1,2,3,4]
|
||||
|
||||
bool bb
|
||||
ubyte cc
|
||||
@ -915,7 +915,7 @@ class TestProg8Parser: FunSpec( {
|
||||
main {
|
||||
sub start() {
|
||||
bool @shared cc
|
||||
ubyte[] array = [1,2,3]
|
||||
ubyte [ ] array = [1,2,3]
|
||||
cc = 99 in 12345
|
||||
cc = 9999 in array
|
||||
}
|
||||
|
@ -503,8 +503,16 @@ private fun ExpressionContext.toAst(insideParentheses: Boolean=false) : Expressi
|
||||
if(scoped_identifier()!=null)
|
||||
return scoped_identifier().toAst()
|
||||
|
||||
if(bop!=null)
|
||||
return BinaryExpression(left.toAst(), bop.text.trim(), right.toAst(), toPosition(), insideParentheses=insideParentheses)
|
||||
if(bop!=null) {
|
||||
val operator = bop.text.trim().replace("\\s+".toRegex(), " ")
|
||||
return BinaryExpression(
|
||||
left.toAst(),
|
||||
operator,
|
||||
right.toAst(),
|
||||
toPosition(),
|
||||
insideParentheses = insideParentheses
|
||||
)
|
||||
}
|
||||
|
||||
if(prefix!=null)
|
||||
return PrefixExpression(prefix.text, expression(0).toAst(), toPosition())
|
||||
|
@ -1,10 +1,9 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
fix the ubyte[<space>] parser error.
|
||||
word starw; for starw in 50 downto 0 -> compiler error word loop variable can only loop over bytes or words
|
||||
|
||||
word starw
|
||||
for starw in 50 downto 0 -> compiler error word loop variable can only loop over bytes or words
|
||||
chess prg got bigger again. why?
|
||||
|
||||
Regenerate skeleton doc files.
|
||||
|
||||
|
@ -16,7 +16,7 @@ main {
|
||||
|
||||
ubyte[] stuff1=[1,2,3]
|
||||
ubyte [] stuff2=[1,2,3]
|
||||
ubyte[ ] stuff3=[1,2,3] ; TODO fix parse error
|
||||
ubyte[ ] stuff3=[1,2,3]
|
||||
stuff1[1]++
|
||||
stuff2[1]++
|
||||
stuff3[1]++
|
||||
|
@ -63,9 +63,9 @@ SHARED : '@shared' ;
|
||||
|
||||
SPLIT: '@split' ;
|
||||
|
||||
ARRAYSIG :
|
||||
'[]'
|
||||
;
|
||||
ARRAYSIG : '[' [ \t]* ']' ;
|
||||
|
||||
NOT_IN: 'not' [ \t]+ 'in' [ \t] ;
|
||||
|
||||
|
||||
// A module (file) consists of zero or more directives or blocks, in any order.
|
||||
@ -184,7 +184,7 @@ expression :
|
||||
| left = expression EOL? bop = ('==' | '!=') EOL? right = expression
|
||||
| rangefrom = expression rto = ('to'|'downto') rangeto = expression ('step' rangestep = expression)? // can't create separate rule due to mutual left-recursion
|
||||
| left = expression EOL? bop = 'in' EOL? right = expression
|
||||
| left = expression EOL? bop = ('not in ' | 'not in\t' | 'not in\n' | 'not in\r') EOL? right = expression
|
||||
| left = expression EOL? bop = NOT_IN EOL? right = expression
|
||||
| prefix = 'not' expression
|
||||
| left = expression EOL? bop = 'and' EOL? right = expression
|
||||
| left = expression EOL? bop = 'or' EOL? right = expression
|
||||
|
Loading…
Reference in New Issue
Block a user