lang: parser: Lexer should allow in keyword as a variable name
We move it downwards to allow this case. Whether we want to allow this long-term or not is to be decided.
This commit is contained in:
16
lang/interpret_test/TestAstFunc2/lexer-parser0.txtar
Normal file
16
lang/interpret_test/TestAstFunc2/lexer-parser0.txtar
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
$map = 55
|
||||||
|
$fn = func($in) { # in is a special keyword
|
||||||
|
13
|
||||||
|
}
|
||||||
|
test fmt.printf("%d", $fn(0)) {}
|
||||||
|
func fn($in) { # in is a special keyword
|
||||||
|
42 + $map
|
||||||
|
}
|
||||||
|
test fmt.printf("%d", $fn(0)) {}
|
||||||
|
test fmt.printf("%d", fn(0)) {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[13]
|
||||||
|
Vertex: test[97]
|
||||||
@@ -139,11 +139,6 @@
|
|||||||
lval.str = yylex.Text()
|
lval.str = yylex.Text()
|
||||||
return NOT
|
return NOT
|
||||||
}
|
}
|
||||||
/in/ {
|
|
||||||
yylex.pos(lval) // our pos
|
|
||||||
lval.str = yylex.Text()
|
|
||||||
return IN
|
|
||||||
}
|
|
||||||
/\->/ {
|
/\->/ {
|
||||||
yylex.pos(lval) // our pos
|
yylex.pos(lval) // our pos
|
||||||
lval.str = yylex.Text()
|
lval.str = yylex.Text()
|
||||||
@@ -306,6 +301,11 @@
|
|||||||
lval.str = yylex.Text()
|
lval.str = yylex.Text()
|
||||||
return IDENTIFIER
|
return IDENTIFIER
|
||||||
}
|
}
|
||||||
|
/in/ {
|
||||||
|
yylex.pos(lval) // our pos
|
||||||
|
lval.str = yylex.Text()
|
||||||
|
return IN
|
||||||
|
}
|
||||||
/[A-Z]([a-z0-9_]*[a-z0-9]+)?/
|
/[A-Z]([a-z0-9_]*[a-z0-9]+)?/
|
||||||
{
|
{
|
||||||
yylex.pos(lval) // our pos
|
yylex.pos(lval) // our pos
|
||||||
|
|||||||
Reference in New Issue
Block a user