[antlr-interest] org.antlr.runtime.Parser.getMissingSymbol (Line 70) throws NullPointerException

Dejas Ninethousand dejas9000 at gmail.com
Thu Sep 1 16:51:08 PDT 2011


For this grammar with an empty string input:

grammar PySON;

@parser::header
{
package edu.rice.bioinfo.library.language.pyson._1_0.parsers.antlr.ast;
import java.util.LinkedList;

}

@lexer::header
{
package edu.rice.bioinfo.library.language.pyson._1_0.parsers.antlr.ast;
}



@members
{

public class ErrorWrapper
{
public final String Message;
public final int Line,Col;
 ErrorWrapper(String message, int line, int col)
{
Message = message;
Line = line;
Col = col;
}
}

private List<ErrorWrapper> errors = new LinkedList<ErrorWrapper>();


public void displayRecognitionError(String[] tokenNames,
RecognitionException e)
{
        errors.add(new ErrorWrapper(getErrorMessage(e, tokenNames), e.line,
e.c));
}

public List<ErrorWrapper> getErrors()
{
        return errors;
}

ParseStack stack = new ParseStackAction();

ParseStack getParseStack()
{
return stack;
}


}



blocks : START block* { stack.pushBlocks(); };

block : BEGIN networks_block_body     END
| BEGIN trees_block_body        END
| BEGIN non_networks_block_body END;

networks_block_body
:
NETWORKS translation NETWORK rich_newick_assignment;
trees_block_body
: TREES translation tree_assigment* { stack.pushTreesBlockBody(true); }
| TREES             tree_assigment* { stack.pushTreesBlockBody(false); };

tree_assigment
: tr=(TREE | UTREE) rich_newick_assignment { stack.pushTreeAssignment($tr);
};
rich_newick_assignment
: d=DEFAULT_INDICATOR? identifier '=' rich_newick_string {
stack.pushRichNewickAssignment($d==null); };
translation
: TRANSLATE identifier identifier (',' identifier identifier)* ';';

non_networks_block_body
: ~(NETWORKS | TREES) .*;

rich_newick_string
: str=(.*';') { stack.pushRichNewickString($str.text); };
identifier
: s=(TRANSLATE | TREE | UTREE | NETWORK | BEGIN | NETWORKS | TREES | ID) {
stack.pushIdentifier($s.text); };

DEFAULT_INDICATOR
: '*';
TREE : ('T'|'t')('R'|'r')('E'|'e')('E'|'e');

UTREE : ('U'|'u')('T'|'t')('R'|'r')('E'|'e')('E'|'e');

NETWORK : ('N'|'n')('E'|'e')('T'|'t')('W'|'w')('O'|'o')('R'|'r')('K'|'k');

START
: '#'('N'|'n')('E'|'e')('X'|'x')('U'|'u')('S'|'s');
BEGIN : ('B'|'b')('E'|'e')('G'|'g')('I'|'i')('N'|'n');

TRANSLATE
:
('T'|'t')('R'|'r')('A'|'a')('N'|'n')('S'|'s')('L'|'l')('A'|'a')('T'|'t')('E'|'e');

NETWORKS
: ('N'|'n')('E'|'e')('T'|'t')('W'|'w')('O'|'o')('R'|'r')('K'|'k')('S'|'s');

TREES : ('T'|'t')('R'|'r')('E'|'e')('E'|'e')('S'|'s');
END : ('E'|'e')('N'|'n')('D'|'d')';';

NESTED_ML_COMMENT
  :  '[' (~('[' | ']') | NESTED_ML_COMMENT)* ']' {$channel=HIDDEN;};

WS  :   ( ' '
        | '\t'
        | '\r'
        | '\n'
        ) {$channel=HIDDEN;}
    ;


ID : (('a'..'z')|('A'..'Z')|('0'..'9'))+;


More information about the antlr-interest mailing list