|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The LRTranslatorGrammar
interface describes the
symbolic components of a grammar, relevant to LR parsing
algorithms. The LRTranslatorGrammar contains all the structural
information of the original grammar.
Field Summary | |
static int |
ACTION_PEEK
Constant returned by getContextAction(int, int) to
signal a context stack peek, meaning "change to the context
given at the top of stack". |
static int |
ACTION_PEEL
Constant returned by getContextAction(int, int) to
signal a context stack peel, meaning "execute ACTION_POP until
the top of the stack is equal to the return value of
getContextRegister(int, int) . |
static int |
ACTION_POP
Constant returned by getContextAction(int, int) to
signal a context stack pop, meaning "change back to the
previous stack context". |
static int |
ACTION_POUNCE
Constant returned by getContextAction(int, int) to
signal a context stack pounce, meaning "execute an ACTION_POP,
then an ACTION_PUSH". |
static int |
ACTION_PUSH
Constant returned by getContextAction(int, int) to
signal a context stack push, meaning "shift to the context
having the ID given by the return value of
getContextRegister(int, int) ". |
static int |
UNDEFINED
Constant used to indicate general undefined conditions. |
static int |
UNDEFINED_CONTEXT
Constant used to indicate the non-definition of a particular context. |
static int |
UNDEFINED_NONTERMINAL
Constant used to indicate the non-definition of a particular nonterminal. |
static int |
UNDEFINED_PRODUCTION
Constant used to indicate the non-definition of a particular production. |
static int |
UNDEFINED_SYMBOL
Constant used to indicate the non-definition of a particular grammar symbol (where a grammar symbol defined as a terminal or a nonterminal). |
static int |
UNDEFINED_TERMINAL
Constant used to indicate the non-definition of a particular terminal. |
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 contextID,
int symbolID)
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 contextID,
int symbolID)
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 contextID)
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 |
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 productionID)
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 productionID)
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 productionID)
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 terminalID)
Returns a list of contexts in which this terminal is defined. |
Object |
getTerminalRegexp(int terminalID)
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 . |
Methods inherited from interface org.inxar.syntacs.translator.TranslatorGrammar |
getName, getVersion, newTranslator, newTranslator |
Field Detail |
public static final int ACTION_PEEK
getContextAction(int, int)
to
signal a context stack peek, meaning "change to the context
given at the top of stack". This effectively means "no change"
and is the most common context stack action.public static final int ACTION_POP
getContextAction(int, int)
to
signal a context stack pop, meaning "change back to the
previous stack context".public static final int ACTION_PUSH
getContextAction(int, int)
to
signal a context stack push, meaning "shift to the context
having the ID given by the return value of
getContextRegister(int, int)
".public static final int ACTION_PEEL
getContextAction(int, int)
to
signal a context stack peel, meaning "execute ACTION_POP until
the top of the stack is equal to the return value of
getContextRegister(int, int)
. If the stack
becomes empty, PUSH the register value." This has the effect
of removing plates from the buffet table until the top plate is
blue, or if all plates are gone, put a single blue plate on the
table. This action is useful during error recovery
synchronization routines where the stack should be put in a
known and minimal state.public static final int ACTION_POUNCE
getContextAction(int, int)
to
signal a context stack pounce, meaning "execute an ACTION_POP,
then an ACTION_PUSH". The name "pounce" is derived from two
points: (1) stack instructions starting with "p" have a certain
ring to them, (2) the action of pouncing resembles something
that goes down (a crouching tiger, perhaps) and then goes back
up. The effect is ACTION_POUNCE is to change the context
without having to POP it later. Exclusive use of ACTION_POUNCE
makes the context stack appear like a single scalar value as
demonstrated by other lexers having start states (such as
flex).public static final int UNDEFINED
public static final int UNDEFINED_CONTEXT
public static final int UNDEFINED_TERMINAL
public static final int UNDEFINED_NONTERMINAL
public static final int UNDEFINED_PRODUCTION
public static final int UNDEFINED_SYMBOL
Method Detail |
public IntArray getContexts()
IntArray
.public IntArray getTerminals()
IntArray
.public IntArray getNonTerminals()
IntArray
.public IntArray getProductions()
IntArray
.public String getContext(int ID)
null
if no such ID is known.public String getTerminal(int ID)
null
if no such ID is known.public String getNonTerminal(int ID)
null
if no such ID is known.public String getProduction(int ID)
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.public IntArray getContextTerminals(int contextID)
null
if no such ID is known.public int getContextAction(int contextID, int symbolID)
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.public int getContextRegister(int contextID, int symbolID)
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.public int getStartContext()
public IntArray getTerminalContexts(int terminalID)
public Object getTerminalRegexp(int terminalID)
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.public int getProductionNonTerminal(int productionID)
productionID
or
UNDEFINED_PRODUCTION
if no such production is known.public IntArray getProductionSymbols(int productionID)
IntArray
or null
if no such ID is known.public int getProductionLength(int productionID)
UNDEFINED_PRODUCTION
if no such ID is known.public int getGoalNonTerminal()
UNDEFINED_NONTERMINAL
is no such goal symbol has
been set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |