[antlr-interest] Island grammar for reading shell commands

Jim Idle jimi at temporal-wave.com
Tue Nov 30 13:09:50 PST 2010


Isn't this when the grammar is trying to use a token that the lexer has not
defined?

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Terence Parr
> Sent: Tuesday, November 30, 2010 1:08 PM
> To: Bill Lear
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Island grammar for reading shell commands
> 
> Wow. input.LT(1) or LT(-1) is returning null.
> 
> I'd turn on -trace option of antlr then recompile and retry. that may
> say more T On Nov 30, 2010, at 12:59 PM, Bill Lear wrote:
> 
> > On Tuesday, November 30, 2010 at 11:25:18 (-0800) Terence Parr
> writes:
> >>
> >> On Nov 29, 2010, at 7:00 PM, Bill Lear wrote:
> >>
> >>> I've followed the sensible advice to create an island grammar to
> >>> deal with parsing an unstructured shell command along with more
> >>> structured input.  Unfortunately, when I follow the examples as
> >>> given in the Antlr examples zip file, I get very close, but then
> >>> either a NULL pointer exception bites, or I can only parse one line
> of "island"
> >>> input --- I can't figure out how to return control back to the
> "sea"
> >>> parser and have it read more input.
> >>
> >> Can you tell us where it gets null ptr?
> >
> > Surely.  Here you go:
> >
> > % cat input | java Command
> > Got shell.  Going native.
> > Exception in thread "main" java.lang.NullPointerException
> >        at org.antlr.runtime.Parser.getMissingSymbol(Parser.java:70)
> >        at
> org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecogni
> zer.java:604)
> >        at
> org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
> >        at ShellParser.shell(ShellParser.java:48)
> >        at CommandLexer.mSHELL(CommandLexer.java:57)
> >        at CommandLexer.mTokens(CommandLexer.java:688)
> >        at org.antlr.runtime.Lexer.nextToken(Lexer.java:84)
> >        at
> org.antlr.runtime.CommonTokenStream.fillBuffer(CommonTokenStream.java:9
> 5)
> >        at
> org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:238)
> >        at
> org.antlr.runtime.CommonTokenStream.LA(CommonTokenStream.java:300)
> >        at CommandParser.commands(CommandParser.java:56)
> >        at Command.main(Command.java:8)
> >
> > Let me know if I can do anything further to narrow it down for you.
> >
> >
> > Bill
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list