[antlr-interest] Island grammar for reading shell commands
Bill Lear
rael at zopyra.com
Tue Nov 30 12:59:28 PST 2010
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(BaseRecognizer.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:95)
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
More information about the antlr-interest
mailing list