lang: parser: Define variable identifier in the parser

Instead of in the lexer. I think this simplifies things and gives the
parser more information which should hopefully make it easier to parse
without shift/reduce conflicts.
This commit is contained in:
James Shubin
2023-10-11 14:48:22 -04:00
parent 04fd330733
commit 9e7b7fbb3a
2 changed files with 22 additions and 34 deletions

View File

@@ -295,14 +295,6 @@
panic(fmt.Sprintf("error lexing FLOAT, got: %v", err))
}
}
/\$[a-z]([a-z0-9_]*[a-z0-9]+)?/
{
// an alternate pattern: /\$[a-z](|[a-z0-9_]*[a-z0-9])/
yylex.pos(lval) // our pos
s := yylex.Text()
lval.str = s[1:len(s)] // remove the leading $
return VAR_IDENTIFIER
}
/[a-z]([a-z0-9_]*[a-z0-9]+)?/
{
yylex.pos(lval) // our pos