| java.lang.Object fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilder
SyntaxBuilder | public class SyntaxBuilder (Code) | | Connects SyntaxSeparation and LexerBuilder.
SyntaxBuilder builds a Syntax object from a text input which can be
File, InputStream, Reader, String, StringBuffer. Mind that you DO NOT need
a SyntaxBuilder to create a Syntax from a String [][] or a List of rule Lists!
Following symbols can be used within the syntax specification text (spaces are ignored):
a ::= b? ; // a derives to one or none b
a ::= b* ; // a derives to any number of b including zero
a ::= b+ ; // a derives to any number of b excluding zero
a ::= (b c)* d ; // grouping of b and c by parenthesis
a ::= b | c | ; // a derives to b or c or nothing
start ::= "BEGIN" ; // a fixed terminal string
letter ::= 'a' .. 'z' ; // character set a-z
newline ::= '\r' | '\n' | '\r' '\n' ; // newlines of all wellknown platforms
positive ::= digit - '0' ; // digit but not zero
id ::= `identifier` ; // using the pre-built lexer rules for identifier (lexer ruleref)
source ::= char - comment ; // source is all characters, but without comments
This EBNF-like language is case-sensitive and differs from EBNF only at these symbols:
. { } < > [ ]. Archetype was the notation used by the w3c.
author: (c) 2002, Fritz Ritzberger |
Constructor Summary | |
public | SyntaxBuilder(Object syntaxInput) Parse a syntax specification text and process it to a Syntax object. |
Method Summary | |
public List | getInitialNonterminals() Returns the list of initial nonterminals (before parenthesis and quantifiers get resolved). | public Lexer | getLexer() Returns a Lexer for the built syntax. | public Syntax | getParserSyntax() Returns only the ready-made parser syntax (to feed the parser tables). | public Syntax | getSyntax() Returns the whole syntax (both parser and lexer syntax). | public static void | main(String[] args) Creates SyntaxBuilderParserTables.java (in this directory) from the rules defined in SyntaxBuilderSemantic. | public Syntax | resolveSingulars() Resolves all singular rules (only one symbol on right side, only one occurence). |
SyntaxBuilder | public SyntaxBuilder(Object syntaxInput) throws SyntaxException, LexerException, ParserBuildException, IOException(Code) | | Parse a syntax specification text and process it to a Syntax object.
The syntax, a Lexer, a parserSyntax and a token-symbol list will be retrieveable after construction.
Parameters: syntaxInput - text to parse and build a syntax from, File, InputStream, Reader, String, StringBuffer.If InputStream is used, no Reader will be wrapped around (raw byte input). |
getInitialNonterminals | public List getInitialNonterminals()(Code) | | Returns the list of initial nonterminals (before parenthesis and quantifiers get resolved).
This is for internal use in SourceGenerator.
|
getParserSyntax | public Syntax getParserSyntax() throws SyntaxException(Code) | | Returns only the ready-made parser syntax (to feed the parser tables).
|
getSyntax | public Syntax getSyntax()(Code) | | Returns the whole syntax (both parser and lexer syntax).
|
main | public static void main(String[] args)(Code) | | Creates SyntaxBuilderParserTables.java (in this directory) from the rules defined in SyntaxBuilderSemantic.
|
resolveSingulars | public Syntax resolveSingulars()(Code) | | Resolves all singular rules (only one symbol on right side, only one occurence).
This must be called directly after construction to have an effect.
|
|
|