|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.inxar.syntacs.translator.syntacs.SyntacsGrammar
Automatically generated by Syntacs Translation Toolkit on Fri Jul 06 12:05:11 PDT 2001
# GRAMMAR DECLARATION this is syntacs version 0.1.0; # PROPERTY DEFINITIONS property viz-namespace = "syntacs"; property viz-dpa-size = "20,20"; property viz-syntactic = "true"; property author-email = "pcj@inxar.org"; property viz-dpa-concentrate-edges = "true"; property author = "Paul Cody Johnston"; property viz-dpa-hide-loopback-edges = "false"; property compile-interpreter-classname = "com.inxar.syntacs.translator.syntacs.SyntacsInterpreter"; property viz-sourcepath = "./grammar"; property viz-dfa-size = "12,12"; property viz-dfa-rankdir = "TB"; property viz-lexical = "true"; property compile-namespace = "com.inxar.syntacs.translator.syntacs"; property compile-dpa-constructor-method = "LALR1"; property compile-sourcepath = "./src"; # TERMINAL DECLARATIONS terminal COMMENT; terminal WHITESPACE; terminal THIS; terminal IS; terminal VERSION; terminal START; terminal IN; terminal CONTEXT; terminal TERMINAL; terminal NONTERMINAL; terminal REDUCE; terminal INCLUDES; terminal WHEN; terminal SHIFTS; terminal UNSHIFTS; terminal ACCEPT; terminal PROPERTY; terminal MATCHES; terminal IDENT; terminal STRING; terminal VERSION_STRING; terminal COMMA; terminal SEMI; terminal EQUALS; # TERMINAL DEFINITIONS COMMENT matches "(#[^\n\r]*(\n|(\r\n)))"; WHITESPACE matches "(\t|\n|\v|\r|\s)+"; IDENT matches "([_a-zA-Z][-_a-zA-Z0-9]*)"; STRING matches "((\")([^\"\\]|(\\[^\n]))*(\"))"; VERSION_STRING matches "([0-9]+.[0-9]+.[0-9]+)"; COMMA matches ","; SEMI matches "\;"; EQUALS matches "="; # NONTERMINAL DECLARATIONS nonterminal Goal; nonterminal Statement; nonterminal ThisIsStatement; nonterminal TerminalStatement; nonterminal MatchesStatement; nonterminal ContextStatement; nonterminal StartInStatement; nonterminal IncludesStatement; nonterminal NonterminalStatement; nonterminal ReduceStatement; nonterminal AcceptWhenStatement; nonterminal PropertyStatement; nonterminal StatementList; nonterminal InstructionList; nonterminal NonterminalList; nonterminal IdentList; nonterminal Instruction; # NONTERMINAL DEFINITIONS reduce Goal when ThisIsStatement StatementList; reduce StatementList when Statement; reduce StatementList when StatementList Statement; reduce Statement when TerminalStatement; reduce Statement when MatchesStatement; reduce Statement when ContextStatement; reduce Statement when StartInStatement; reduce Statement when IncludesStatement; reduce Statement when NonterminalStatement; reduce Statement when ReduceStatement; reduce Statement when AcceptWhenStatement; reduce Statement when PropertyStatement; reduce ThisIsStatement when THIS IS IDENT VERSION VERSION_STRING SEMI; reduce TerminalStatement when TERMINAL IdentList SEMI; reduce MatchesStatement when IDENT MATCHES STRING SEMI; reduce NonterminalStatement when NONTERMINAL IdentList SEMI; reduce ContextStatement when CONTEXT IdentList SEMI; reduce StartInStatement when START IN CONTEXT IDENT SEMI; reduce IncludesStatement when IDENT INCLUDES InstructionList SEMI; reduce ReduceStatement when REDUCE IDENT WHEN NonterminalList SEMI; reduce AcceptWhenStatement when ACCEPT WHEN IDENT SEMI; reduce PropertyStatement when PROPERTY IDENT EQUALS STRING SEMI; reduce IdentList when IDENT; reduce IdentList when IdentList COMMA IDENT; reduce NonterminalList when IDENT; reduce NonterminalList when NonterminalList IDENT; reduce InstructionList when Instruction; reduce InstructionList when InstructionList COMMA Instruction; reduce Instruction when IDENT; reduce Instruction when IDENT SHIFTS IDENT; reduce Instruction when IDENT UNSHIFTS; accept when Goal; # CONTEXT DECLARATIONS context default; # CONTEXT DEFINITIONS default includes COMMENT, WHITESPACE, IDENT, STRING, VERSION_STRING, COMMA, SEMI, EQUALS; start in context default;
Field Summary | |
static int |
C_default
Constant ID for default |
static int |
N_AcceptWhenStatement
NonTerminal ID for AcceptWhenStatement |
static int |
N_ContextStatement
NonTerminal ID for ContextStatement |
static int |
N_Goal
NonTerminal ID for Goal |
static int |
N_IdentList
NonTerminal ID for IdentList |
static int |
N_IncludesStatement
NonTerminal ID for IncludesStatement |
static int |
N_Instruction
NonTerminal ID for Instruction |
static int |
N_InstructionList
NonTerminal ID for InstructionList |
static int |
N_MatchesStatement
NonTerminal ID for MatchesStatement |
static int |
N_NonterminalList
NonTerminal ID for NonterminalList |
static int |
N_NonterminalStatement
NonTerminal ID for NonterminalStatement |
static int |
N_PropertyStatement
NonTerminal ID for PropertyStatement |
static int |
N_ReduceStatement
NonTerminal ID for ReduceStatement |
static int |
N_StartInStatement
NonTerminal ID for StartInStatement |
static int |
N_Statement
NonTerminal ID for Statement |
static int |
N_StatementList
NonTerminal ID for StatementList |
static int |
N_TerminalStatement
NonTerminal ID for TerminalStatement |
static int |
N_ThisIsStatement
NonTerminal ID for ThisIsStatement |
static int |
P_AcceptWhenStatement__ACCEPT_WHEN_IDENT_SEMI
Production ID for AcceptWhenStatement__ACCEPT_WHEN_IDENT_SEMI |
static int |
P_ContextStatement__CONTEXT_IdentList_SEMI
Production ID for ContextStatement__CONTEXT_IdentList_SEMI |
static int |
P_Goal__ThisIsStatement_StatementList
Production ID for Goal__ThisIsStatement_StatementList |
static int |
P_IdentList__IDENT
Production ID for IdentList__IDENT |
static int |
P_IdentList__IdentList_COMMA_IDENT
Production ID for IdentList__IdentList_COMMA_IDENT |
static int |
P_IncludesStatement__IDENT_INCLUDES_InstructionList_SEMI
Production ID for IncludesStatement__IDENT_INCLUDES_InstructionList_SEMI |
static int |
P_Instruction__IDENT
Production ID for Instruction__IDENT |
static int |
P_Instruction__IDENT_SHIFTS_IDENT
Production ID for Instruction__IDENT_SHIFTS_IDENT |
static int |
P_Instruction__IDENT_UNSHIFTS
Production ID for Instruction__IDENT_UNSHIFTS |
static int |
P_InstructionList__Instruction
Production ID for InstructionList__Instruction |
static int |
P_InstructionList__InstructionList_COMMA_Instruction
Production ID for InstructionList__InstructionList_COMMA_Instruction |
static int |
P_MatchesStatement__IDENT_MATCHES_STRING_SEMI
Production ID for MatchesStatement__IDENT_MATCHES_STRING_SEMI |
static int |
P_NonterminalList__IDENT
Production ID for NonterminalList__IDENT |
static int |
P_NonterminalList__NonterminalList_IDENT
Production ID for NonterminalList__NonterminalList_IDENT |
static int |
P_NonterminalStatement__NONTERMINAL_IdentList_SEMI
Production ID for NonterminalStatement__NONTERMINAL_IdentList_SEMI |
static int |
P_PropertyStatement__PROPERTY_IDENT_EQUALS_STRING_SEMI
Production ID for PropertyStatement__PROPERTY_IDENT_EQUALS_STRING_SEMI |
static int |
P_ReduceStatement__REDUCE_IDENT_WHEN_NonterminalList_SEMI
Production ID for ReduceStatement__REDUCE_IDENT_WHEN_NonterminalList_SEMI |
static int |
P_StartInStatement__START_IN_CONTEXT_IDENT_SEMI
Production ID for StartInStatement__START_IN_CONTEXT_IDENT_SEMI |
static int |
P_Statement__AcceptWhenStatement
Production ID for Statement__AcceptWhenStatement |
static int |
P_Statement__ContextStatement
Production ID for Statement__ContextStatement |
static int |
P_Statement__IncludesStatement
Production ID for Statement__IncludesStatement |
static int |
P_Statement__MatchesStatement
Production ID for Statement__MatchesStatement |
static int |
P_Statement__NonterminalStatement
Production ID for Statement__NonterminalStatement |
static int |
P_Statement__PropertyStatement
Production ID for Statement__PropertyStatement |
static int |
P_Statement__ReduceStatement
Production ID for Statement__ReduceStatement |
static int |
P_Statement__StartInStatement
Production ID for Statement__StartInStatement |
static int |
P_Statement__TerminalStatement
Production ID for Statement__TerminalStatement |
static int |
P_StatementList__Statement
Production ID for StatementList__Statement |
static int |
P_StatementList__StatementList_Statement
Production ID for StatementList__StatementList_Statement |
static int |
P_TerminalStatement__TERMINAL_IdentList_SEMI
Production ID for TerminalStatement__TERMINAL_IdentList_SEMI |
static int |
P_ThisIsStatement__THIS_IS_IDENT_VERSION_VERSION_STRING_SEMI
Production ID for ThisIsStatement__THIS_IS_IDENT_VERSION_VERSION_STRING_SEMI |
static int |
T_ACCEPT
Terminal ID for ACCEPT |
static int |
T_COMMA
Terminal ID for COMMA |
static int |
T_COMMENT
Terminal ID for COMMENT |
static int |
T_CONTEXT
Terminal ID for CONTEXT |
static int |
T_EQUALS
Terminal ID for EQUALS |
static int |
T_IDENT
Terminal ID for IDENT |
static int |
T_IN
Terminal ID for IN |
static int |
T_INCLUDES
Terminal ID for INCLUDES |
static int |
T_IS
Terminal ID for IS |
static int |
T_MATCHES
Terminal ID for MATCHES |
static int |
T_NONTERMINAL
Terminal ID for NONTERMINAL |
static int |
T_PROPERTY
Terminal ID for PROPERTY |
static int |
T_REDUCE
Terminal ID for REDUCE |
static int |
T_SEMI
Terminal ID for SEMI |
static int |
T_SHIFTS
Terminal ID for SHIFTS |
static int |
T_START
Terminal ID for START |
static int |
T_STRING
Terminal ID for STRING |
static int |
T_TERMINAL
Terminal ID for TERMINAL |
static int |
T_THIS
Terminal ID for THIS |
static int |
T_UNSHIFTS
Terminal ID for UNSHIFTS |
static int |
T_VERSION
Terminal ID for VERSION |
static int |
T_VERSION_STRING
Terminal ID for VERSION_STRING |
static int |
T_WHEN
Terminal ID for WHEN |
static int |
T_WHITESPACE
Terminal ID for WHITESPACE |
Fields inherited from interface org.inxar.syntacs.translator.lr.LRTranslatorGrammar |
ACTION_PEEK, ACTION_PEEL, ACTION_POP, ACTION_POUNCE, ACTION_PUSH, UNDEFINED, UNDEFINED_CONTEXT, UNDEFINED_NONTERMINAL, UNDEFINED_PRODUCTION, UNDEFINED_SYMBOL, UNDEFINED_TERMINAL |
Constructor Summary | |
SyntacsGrammar()
|
Method Summary | |
String |
getContext(int ID)
Returns the name of the context having the given ID or null if no such ID is known. |
int |
getContextAction(int cID,
int tID)
Returns the action defined for the given grammar symbol in the given context as one of the ACTION_XXX constants
in this interface. |
int |
getContextRegister(int cID,
int tID)
Returns an integer stored at the value of the given contextID and symbolID . |
IntArray |
getContexts()
Returns the list of context ID numbers as an IntArray . |
IntArray |
getContextTerminals(int ID)
Returns a list of terminals defined within the context having the given ID or null if no such ID is known. |
int |
getGoalNonTerminal()
Returns the ID of the goal symbol (a nonterminal) or UNDEFINED_NONTERMINAL is no such goal symbol has
been set. |
String |
getName()
Returns the name of the Translator . |
String |
getNonTerminal(int ID)
Returns the name of the nonterminal having the given ID or null if no such ID is known. |
IntArray |
getNonTerminals()
Returns the list of nonterminal ID numbers as an IntArray . |
String |
getProduction(int ID)
Returns the name of the production having the given ID or null if no such ID is known. |
int |
getProductionLength(int ID)
Returns the length of the list of grammar symbols of the right-hand-side of the production having the given ID or UNDEFINED_PRODUCTION if no such ID is known. |
int |
getProductionNonTerminal(int ID)
Returns the ID of the nonterminal obtained by reduction of the given productionID or
UNDEFINED_PRODUCTION if no such production is known. |
IntArray |
getProductions()
Returns the list of production ID numbers as an IntArray . |
IntArray |
getProductionSymbols(int ID)
Returns the list of grammar symbols of the right-hand-side of the production having the given ID as an IntArray
or null if no such ID is known. |
int |
getStartContext()
Returns the ID of the initial context. |
String |
getTerminal(int ID)
Returns the name of the terminal having the given ID or null if no such ID is known. |
IntArray |
getTerminalContexts(int ID)
Returns a list of contexts in which this terminal is defined. |
Object |
getTerminalRegexp(int ID)
Returns the regular expression String for the
terminal having the given ID or null if no such ID
is known. |
IntArray |
getTerminals()
Returns the list of terminal ID numbers as an IntArray . |
String |
getVersion()
Returns the version number given to this grammar. |
Translator |
newTranslator()
Returns a new Translator for this
TranslatorGrammar having some default set of
properties. |
Translator |
newTranslator(Properties p)
Returns a new Translator for this
TranslatorGrammar using the given
Properties . |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int C_default
public static final int T_COMMENT
public static final int T_WHITESPACE
public static final int T_THIS
public static final int T_IS
public static final int T_VERSION
public static final int T_START
public static final int T_IN
public static final int T_CONTEXT
public static final int T_TERMINAL
public static final int T_NONTERMINAL
public static final int T_REDUCE
public static final int T_INCLUDES
public static final int T_WHEN
public static final int T_SHIFTS
public static final int T_UNSHIFTS
public static final int T_ACCEPT
public static final int T_PROPERTY
public static final int T_MATCHES
public static final int T_IDENT
public static final int T_STRING
public static final int T_VERSION_STRING
public static final int T_COMMA
public static final int T_SEMI
public static final int T_EQUALS
public static final int N_Goal
public static final int N_Statement
public static final int N_ThisIsStatement
public static final int N_TerminalStatement
public static final int N_MatchesStatement
public static final int N_ContextStatement
public static final int N_StartInStatement
public static final int N_IncludesStatement
public static final int N_NonterminalStatement
public static final int N_ReduceStatement
public static final int N_AcceptWhenStatement
public static final int N_PropertyStatement
public static final int N_StatementList
public static final int N_InstructionList
public static final int N_NonterminalList
public static final int N_IdentList
public static final int N_Instruction
public static final int P_Goal__ThisIsStatement_StatementList
public static final int P_StatementList__Statement
public static final int P_StatementList__StatementList_Statement
public static final int P_Statement__TerminalStatement
public static final int P_Statement__MatchesStatement
public static final int P_Statement__ContextStatement
public static final int P_Statement__StartInStatement
public static final int P_Statement__IncludesStatement
public static final int P_Statement__NonterminalStatement
public static final int P_Statement__ReduceStatement
public static final int P_Statement__AcceptWhenStatement
public static final int P_Statement__PropertyStatement
public static final int P_ThisIsStatement__THIS_IS_IDENT_VERSION_VERSION_STRING_SEMI
public static final int P_TerminalStatement__TERMINAL_IdentList_SEMI
public static final int P_MatchesStatement__IDENT_MATCHES_STRING_SEMI
public static final int P_NonterminalStatement__NONTERMINAL_IdentList_SEMI
public static final int P_ContextStatement__CONTEXT_IdentList_SEMI
public static final int P_StartInStatement__START_IN_CONTEXT_IDENT_SEMI
public static final int P_IncludesStatement__IDENT_INCLUDES_InstructionList_SEMI
public static final int P_ReduceStatement__REDUCE_IDENT_WHEN_NonterminalList_SEMI
public static final int P_AcceptWhenStatement__ACCEPT_WHEN_IDENT_SEMI
public static final int P_PropertyStatement__PROPERTY_IDENT_EQUALS_STRING_SEMI
public static final int P_IdentList__IDENT
public static final int P_IdentList__IdentList_COMMA_IDENT
public static final int P_NonterminalList__IDENT
public static final int P_NonterminalList__NonterminalList_IDENT
public static final int P_InstructionList__Instruction
public static final int P_InstructionList__InstructionList_COMMA_Instruction
public static final int P_Instruction__IDENT
public static final int P_Instruction__IDENT_SHIFTS_IDENT
public static final int P_Instruction__IDENT_UNSHIFTS
Constructor Detail |
public SyntacsGrammar()
Method Detail |
public String getContext(int ID)
LRTranslatorGrammar
null
if no such ID is known.getContext
in interface LRTranslatorGrammar
public int getContextAction(int cID, int tID)
LRTranslatorGrammar
ACTION_XXX
constants
in this interface. If the contextID or symbolID is not known,
UNDEFINED_CONTEXT
or UNDEFINED_SYMBOL
will be returned. Note: If UNDEFINED_SYMBOL is returned the ID
may still be a valid terminal or nonterminal, but it not a
member of the given context.getContextAction
in interface LRTranslatorGrammar
public int getContextRegister(int cID, int tID)
LRTranslatorGrammar
contextID
and symbolID
. This is used
in conjunction with getContextAction(int, int)
such that the second member in the tuple (action, register) is
returned. If the contextID or symbolID is not known,
UNDEFINED_CONTEXT
or UNDEFINED_SYMBOL
will be returned.getContextRegister
in interface LRTranslatorGrammar
public IntArray getContextTerminals(int ID)
LRTranslatorGrammar
null
if no such ID is known.getContextTerminals
in interface LRTranslatorGrammar
public IntArray getContexts()
LRTranslatorGrammar
IntArray
.getContexts
in interface LRTranslatorGrammar
public int getGoalNonTerminal()
LRTranslatorGrammar
UNDEFINED_NONTERMINAL
is no such goal symbol has
been set.getGoalNonTerminal
in interface LRTranslatorGrammar
public String getName()
TranslatorGrammar
Translator
.getName
in interface TranslatorGrammar
public String getNonTerminal(int ID)
LRTranslatorGrammar
null
if no such ID is known.getNonTerminal
in interface LRTranslatorGrammar
public IntArray getNonTerminals()
LRTranslatorGrammar
IntArray
.getNonTerminals
in interface LRTranslatorGrammar
public String getProduction(int ID)
LRTranslatorGrammar
null
if no such ID is known. The
String
has the format "nonterminal: sym1
sym2 sym3
" such that the nonterminal name is the first
part of the string, followed by a colon, followed by a space
delimited list of symbols.getProduction
in interface LRTranslatorGrammar
public int getProductionLength(int ID)
LRTranslatorGrammar
UNDEFINED_PRODUCTION
if no such ID is known.getProductionLength
in interface LRTranslatorGrammar
public int getProductionNonTerminal(int ID)
LRTranslatorGrammar
productionID
or
UNDEFINED_PRODUCTION
if no such production is known.getProductionNonTerminal
in interface LRTranslatorGrammar
public IntArray getProductionSymbols(int ID)
LRTranslatorGrammar
IntArray
or null
if no such ID is known.getProductionSymbols
in interface LRTranslatorGrammar
public IntArray getProductions()
LRTranslatorGrammar
IntArray
.getProductions
in interface LRTranslatorGrammar
public int getStartContext()
LRTranslatorGrammar
getStartContext
in interface LRTranslatorGrammar
public String getTerminal(int ID)
LRTranslatorGrammar
null
if no such ID is known.getTerminal
in interface LRTranslatorGrammar
public IntArray getTerminalContexts(int ID)
LRTranslatorGrammar
getTerminalContexts
in interface LRTranslatorGrammar
public Object getTerminalRegexp(int ID)
LRTranslatorGrammar
String
for the
terminal having the given ID or null
if no such ID
is known. If the terminal ID is valid but no definition has
been provided for that terminal, the empty string
""
will be returned.getTerminalRegexp
in interface LRTranslatorGrammar
public IntArray getTerminals()
LRTranslatorGrammar
IntArray
.getTerminals
in interface LRTranslatorGrammar
public String getVersion()
TranslatorGrammar
getVersion
in interface TranslatorGrammar
public Translator newTranslator()
TranslatorGrammar
Translator
for this
TranslatorGrammar
having some default set of
properties.newTranslator
in interface TranslatorGrammar
public Translator newTranslator(Properties p)
TranslatorGrammar
Translator
for this
TranslatorGrammar
using the given
Properties
. The names and values of the elements
in the Properties
may be used to modify or
communicate with the internals of the Translator
instance (such as turning on debugging). The specifics
reagarding the names and values of the properties are specific
to the translator itself and need be documented elsewhere.newTranslator
in interface TranslatorGrammar
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |