| java.lang.Object fri.patterns.interpreter.parsergenerator.builder.SerializedObject fri.patterns.interpreter.parsergenerator.builder.SerializedParser
SerializedParser | public class SerializedParser extends SerializedObject (Code) | | This class is definitely the shortest way to construct a Parser (with Lexer) for a Syntax.
It uses all serialization utils in this package to quickly build a parsing environment.
This factory accepts a syntax where parser and lexer rules were mixed.
Example (syntax input from a file):
File ebnfFile = new File("MySyntax.syntax");
Parser parser = new SerializedParser().get(ebnfFile);
or (syntax input from a Reader, must pass a filename):
Reader ebnfReader = new InputStreamReader(MySyntaxSemantic.class.getResourceAsStream("MySyntax.syntax"));
Parser parser = new SerializedParser().get(ebnfReader, "MySyntax");
author: (c) 2002, Fritz Ritzberger |
Constructor Summary | |
public | SerializedParser() Create a Parser factory that caches built Lexers. | public | SerializedParser(boolean production) Create a Parser factory that caches built Lexers. |
Method Summary | |
public Parser | get(Object syntaxInput) Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. | public Parser | get(Object syntaxInput, String baseName) Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts. | public Parser | get(Class parserType, Object syntaxInput) Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: parserType - the class of ParserTables to create for the syntax (LALRParserTables.class is default). Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. | public Parser | get(Class parserType, Object syntaxInput, String baseName) Builds the parsing environment from scratch if not found its parts in filesystem, else loads all serialized parts. | public static void | main(String[] args) Test main. | protected SerializedLexer | newSerializedLexer() To be overridden when a modified SerializedLexer is needed. |
PARSERFILE_SUFFIX | final public static String PARSERFILE_SUFFIX(Code) | | The suffix for serialized Parser files.
|
PRODUCTION | protected boolean PRODUCTION(Code) | | |
SerializedParser | public SerializedParser()(Code) | | Create a Parser factory that caches built Lexers.
|
SerializedParser | public SerializedParser(boolean production)(Code) | | Create a Parser factory that caches built Lexers. @param production when false the Parser will not be serialized.
|
get | public Parser get(Object syntaxInput) throws Exception(Code) | | Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. Parser, built from scratch or loaded from filesystem. |
get | public Parser get(Object syntaxInput, String baseName) throws Exception(Code) | | Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. Parameters: baseName - basename for serialization, can be null Parser, built from scratch or loaded from filesystem. |
get | public Parser get(Class parserType, Object syntaxInput) throws Exception(Code) | | Builds the Parser from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: parserType - the class of ParserTables to create for the syntax (LALRParserTables.class is default). Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. Parser, built from scratch or loaded from filesystem. |
get | public Parser get(Class parserType, Object syntaxInput, String baseName) throws Exception(Code) | | Builds the parsing environment from scratch if not found its parts in filesystem, else loads all serialized parts.
Parameters: parserType - the class of ParserTables to create for the syntax (LALRParserTables.class is default). Parameters: syntaxInput - the mixed lexer/parser syntax as File, InputStream, List of Lists, String [][] or Syntax. Parameters: baseName - basename for serialization, can be null Parser, built from scratch or loaded from filesystem. |
main | public static void main(String[] args)(Code) | | Test main. Building serialized Java Parser takes 740, building from scratch takes 4000 millis.
|
|
|