Hi all, Been having trouble with literals lately and I am sure that a tool as cool as ANTLR should definitely have a way out. Here goes - Say we have a grammar...
693
schen@xxxxxxxxxx.xxxx
Sep 1, 1999 3:54 pm
Hi everyone, I'm just getting started using ANTLR 2.6.1 and to begin learning it I thought I'd construct a simple infix calculator that evaluates expressions ...
694
mzukowski@...
Sep 1, 1999 3:58 pm
Where do you need the parser? You can't have the parser tell the lexer when to look for literals and when not to because the parser can be looking ahead by...
695
Dwight Lillie
dwight@...
Sep 1, 1999 6:40 pm
If I have a pattern I'm expecting to parse, and I set up the lexer to return tokens to meet that pattern...how do I detect that it's working in the wrong spot...
696
mzukowski@...
Sep 1, 1999 6:38 pm
Can you give an example? I don't know what you're getting at. Monty...
697
Dwight Lillie
dwight@...
Sep 1, 1999 6:54 pm
In a bunch of text, Viscontini, K.; Oxley, L. JACS 1987, 12, 678-900 I wish to pull out the number stuff, '1987, 12, 678-800' I could do it in the lexer, I...
698
mzukowski@...
Sep 1, 1999 6:56 pm
... Aha! It's called a syntactic predicate, and it means "try this, if it works do the following rule, if not then try the next alternative." e.g.: rule: (...
699
Dwight Lillie
dwight@...
Sep 1, 1999 7:20 pm
Ok, this is good. It gets me part of what I want, I think. But is there a way, if I catch the MisMatchedToken (or NoViableAlternative) exception to restart...
700
Dwight Lillie
dwight@...
Sep 1, 1999 8:13 pm
How do I detect the beginning and ending positions in the stream of text that is associated w/ a token?...
701
mzukowski@...
Sep 1, 1999 9:22 pm
You have to track that manually. See my field guide about column counting, it also counts absolute character position of the start of a token. You can easily...
702
mzukowski@...
Sep 1, 1999 9:29 pm
There is a consumeUntil(TokenSet) method of the parser which will eat stuff until it sees something in the specified TokenSet. Explore around there to see if...
703
Dwight Lillie
dwight@...
Sep 1, 1999 11:48 pm
Do you have an example of how to use this?...
704
Dwight Lillie
dwight@...
Sep 3, 1999 12:10 am
I'm finding that I don't know how to force the lexer to try an alternative rule when the current one fails. As a trivial example (actually, I think it gets it...
705
Sinan Karasu
sinan.karasu@xxxxxx.x...
Sep 3, 1999 12:41 am
... Make you rules protected, and the use predicates , or alternates. SomeToken: (YEAR) => YEAR { $setType(YEAR); } ... ; protected YEAR:...
706
Jeff K. Hoffman
jeff@xxxxxx.xxxx
Sep 3, 1999 2:58 pm
Hello, I am trying to construct a parser for our web development product using ANTLR. I am new to parsing and lexing in general, and am having problems doing...
707
Dwight Lillie
dwight@xxxx.xxxx
Sep 3, 1999 3:38 pm
ok, I understand this, but my lexer is behaving in ways I don't expect. Clearly I'm a bit brain dead here... I have a grammar that looks like this: author : (...
708
mzukowski@xxx.xxx
Sep 3, 1999 4:00 pm
This sounds very similar to my noweb parser. Perhaps you can learn something from it, though it doesn't handle nesting because it doesn't need to. ...
709
schen@xxxxxxxxxx.xxxx
Sep 3, 1999 2:47 pm
... [ ... ] Nevermind, I answered my own questions =) . . . Sean....
710
Thomas Schumacher
tschumac@xxx.xxx.xxxx...
Sep 6, 1999 6:11 am
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <br>Hi Sinan, <p>Your usage of $setType has the side effect that the <br>lexer...
711
Ben Markle
bmarkle@xxxx.xxx.xxxx
Sep 6, 1999 1:48 pm
Hello, I am building a parser for a programming language (RESOLVE) which supports nested modules. The parser contains some state information about the type of...
712
William Koscho
wkoscho@xxxxxxxx.xxxx
Sep 7, 1999 3:22 pm
Hi, I am trying to read a java source file and im only interested in the package name, imports, classes, and methods defined in each class. I want to ignore...
713
Andrew Bell
andrew.bell@xxxxxxx.x...
Sep 7, 1999 2:56 pm
... This is caused by some of the characters in your java file not being in the lexer's character vocabulary (for instance '<'). There is a bit about this in ...
714
mzukowski@xxx.xxx
Sep 7, 1999 4:46 pm
... This should work, and is the right way to do it. Perhaps post the code you tried, it's probably something simple. ... This might work too, but shouldn't...
715
mzukowski@xxx.xxx
Sep 7, 1999 4:51 pm
... From: Thomas Schumacher [mailto:tschumac@...] Sent: Sunday, September 05, 1999 11:12 PM To: antlr-interest@onelist.com Subject: Re:...
716
William Koscho
wkoscho@xxxxxxxx.xxxx
Sep 7, 1999 5:15 pm
Hi, thanks to everyone who helped me with my "no viable alt to char" problem, but now that I am passed that, and a little bit further I've hit the main...
... the problem with this, is that my rule: method: <stuff> LBRACE nestedPair RBRACE ; now requires a left brace in the nestedPair. If I make it just: method: ...
719
William Koscho
wkoscho@...
Sep 7, 1999 9:15 pm
... The original problem was that I was trying to parse a java src file but I wanted to ignore the body of the methods, so I had something like <parse method...
720
Sinan Karasu
sinan.karasu@...
Sep 7, 1999 10:56 pm
... The above rule , even though correct in spirit, has too much of it. Should really read nestedPair: LBRACE (~(LBRACE | RBRACE) )* (nestedPair)? RBRACE ; or...
721
Peter Williams
pete.williams@...
Sep 7, 1999 11:37 pm
Just as an aside, if you want this rule to really work fully, then you need to add additional logic to 'body' to ignore // ... and /* ... */ comments. ...