[antlr-interest] Token "splitting"
Nathan Eloe
powerofazure at gmail.com
Mon Jun 7 09:44:41 PDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello again everybody.
As I mentioned previously, I'm working on implementing the grammar for bash in ANTLR w/ the output being an AST, and I've run into the following problem:
In bash, to define a variable, it has to be of the form:
name=value
There can be no spaces around the equals sign (bash is a bit strange about its whitespace, which has caused me some fun headaches)
My question is this: if I have:
foo=bar
I'd like the resulting AST to be:
(= foo bar)
However, when I try to implement this as:
arr_var_def2
: NAME EQUALS^ NAME;
or anything similar where I try to define all the tokens at once, it doesn't parse correctly, I believe because it's parsing "foo=bar" as one token.
However, if I do:
arr_var_def
: ARR_VAR_DEF;
ARR_VAR_DEF: NAME EQUALS NAME;
It parses correctly (since ARR_VAR_DEF is one token), but I cannot control the AST output, and it just outputs it as the one token.
I know about http://antlr.markmail.org, but I'm not exactly sure what to search for for this question.
Thank you so much for all the help you have given me thus far.
Nathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
iEYEARECAAYFAkwNIfsACgkQFpoRlVgtqKZaMwCfTWY48VBh4I4AZReYMCCspxZX
NhYAoIEZ3uqxuD5S9o9fZjOrtwYp0PlW
=m4vZ
-----END PGP SIGNATURE-----
More information about the antlr-interest
mailing list