| java.lang.Object fri.patterns.interpreter.parsergenerator.syntax.builder.ArtificialRule
ArtificialRule | class ArtificialRule (Code) | | ArtificialRule is needed to
- create nonterminals and rules for symbols within parenthesis: "(a b c)" -> "_a_b_c_"
- create nonterminals and rules for symbols that were quantified with "*", "+", "?"
The nonterminal names get created from symbols that are converted to names.
Every created nonterminal starts with "_" (Token.ARTIFICIAL_RULE_START_CHARACTER).
Example:
sentence1 ::= word* ;
sentence2 ::= word+ ;
sentence3 ::= word? ;
will be converted to following rules
_sentence1_OPTLIST ::= _sentence1_LIST;
_sentence1_OPTLIST ::= ;
_sentence1_LIST ::= _sentence1_LIST word;
_sentence1_LIST ::= word;
_sentence2_LIST ::= _sentence2_LIST word;
_sentence2_LIST ::= word;
_sentence3_OPT ::= word;
_sentence3_OPT ::= ;
author: (c) 2002 Fritz Ritzberger |
Constructor Summary | |
public | ArtificialRule(List sentencesInParenthesis, String catSym) Creates an artificial rule from an expression within parenthesis. | public | ArtificialRule(Object token, String quantifier) Creates an artificial rule from with a quantifier like "*", "+", "?". |
Method Summary | |
public static List | flattenLists(List deep, List flat) The passed "deep" container contains Lists of arbitrary depth, that means every List
element can be a List. | public List | getRules() Returns all real rules of this artificial rule. | public static void | main(String[] args) | public static void | resolveArtificialRules(List rules, List resultSyntax) Resolves a List of rules that contain ArtificialRules to a
to a list of real rules and stores those in resultSyntax.
Parameters: rules - List of rules to resolve, containing ArtificialRules on the right side. Parameters: resultSyntax - List of rules that will not contain ArtificialRules. | public String | toString() Returns the artificial name of this rule. |
ArtificialRule | public ArtificialRule(List sentencesInParenthesis, String catSym)(Code) | | Creates an artificial rule from an expression within parenthesis.
Argument sentencesInParenthesis holds a List of arbitrary deep Lists
that contain String or ArtificialRule at end.
The method getRules() will return as much rules as are contained on any
level in sentencesInParenthesis.
|
ArtificialRule | public ArtificialRule(Object token, String quantifier)(Code) | | Creates an artificial rule from with a quantifier like "*", "+", "?".
From this some rules are resulting that getRules() will return.
"token" is either String or ArtificialRule.
|
flattenLists | public static List flattenLists(List deep, List flat)(Code) | | The passed "deep" container contains Lists of arbitrary depth, that means every List
element can be a List. This method resolves them to a sequential List of Lists.
Parameters: container - List that contains Lists that contain Lists ... Parameters: result - List containing only Lists, retrieved from the "tree" container. the result flattened List (identical with passed "flat" List). |
getRules | public List getRules()(Code) | | Returns all real rules of this artificial rule.
|
resolveArtificialRules | public static void resolveArtificialRules(List rules, List resultSyntax)(Code) | | Resolves a List of rules that contain ArtificialRules to a
to a list of real rules and stores those in resultSyntax.
Parameters: rules - List of rules to resolve, containing ArtificialRules on the right side. Parameters: resultSyntax - List of rules that will not contain ArtificialRules. Will not be cleared when passed! |
toString | public String toString()(Code) | | Returns the artificial name of this rule.
This is used to represent this rule within other rules.
|
|
|