Package org.lifstools.jgoslin.parser
Klasse Parser<T>
java.lang.Object
org.lifstools.jgoslin.parser.Parser<T>
- Typparameter:
T- the type of a successful parse result.
- Bekannte direkte Unterklassen:
FattyAcidParser,GoslinParser,HmdbParser,LipidMapsParser,ShorthandParser,SumFormulaParser,SwissLipidsParser
Abstract base class for parsers producing a parse result of type T. Uses a
re-implementation of Cocke-Younger-Kasami (CYK) algorithm for context free
grammars.
- Autor:
- Dominik Kopczynski, Nils Hoffmann
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungprotected final classprotected class -
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected intprotected static final charprotected static final longprotected static final Stringprotected static final charprotected Stringprotected static final longprotected longprotected charprotected final ArrayList<org.lifstools.jgoslin.parser.Bitfield> protected static final charprotected static final charprotected static final charprotected static final intprotected static final longprotected boolean -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected longadd_terminal(String text) collect_backwards(long child_rule_index, long parent_rule_index, HashSet<Long> visited, ArrayList<Long> path, ArrayList<ArrayList<Long>> collection) collect_backwards(Long child_rule_index, Long parent_rule_index) collect_one_backwards(Long rule_index) protected longcompute_rule_key(long rule_index_1, long rule_index_2) protected Stringextract_text_based_rules(String grammar, char _quote) protected voidprotected longprotected booleanis_terminal(String product_token, char _quote) abstract BaseParserEventHandler<T> parse(String textToParse, BaseParserEventHandler<T> parserEventHandler) Parse the given text, constructing the output object of type T using the provided parser event handler.parse(String textToParse, BaseParserEventHandler<T> parserEventHandler, boolean throwError) Parse the given text, constructing the output object of type T using the provided parser event handler.Allows the user to specify, if exceptions should be thrown on errors.protected Optional<Parser<T>.ParsingErrors> parse_regular(String text_to_parse, BaseParserEventHandler<T> parserEventHandler) protected voidraise_events(TreeNode node, BaseParserEventHandler parserEventHandler) protected final voidreadGrammar(String grammar) top_nodes(long rule_index)
-
Felddetails
-
SHIFT
protected static final int SHIFT- Siehe auch:
-
MASK
protected static final long MASK- Siehe auch:
-
RULE_ASSIGNMENT
protected static final char RULE_ASSIGNMENT- Siehe auch:
-
RULE_SEPARATOR
protected static final char RULE_SEPARATOR- Siehe auch:
-
RULE_TERMINAL
protected static final char RULE_TERMINAL- Siehe auch:
-
EOF_SIGN
protected static final char EOF_SIGN- Siehe auch:
-
EOF_RULE
protected static final long EOF_RULE- Siehe auch:
-
START_RULE
protected static final long START_RULE- Siehe auch:
-
EOF_RULE_NAME
- Siehe auch:
-
nextFreeRuleIndex
protected long nextFreeRuleIndex -
TtoNT
-
originalTtoNT
-
ruleToNT
-
NTtoNT
-
NTtoRule
-
substitution
-
rightPair
-
avgPair
protected int avgPair -
quote
protected char quote -
grammarName
-
usedEof
protected boolean usedEof -
DEFAULT_QUOTE
protected static final char DEFAULT_QUOTE- Siehe auch:
-
-
Konstruktordetails
-
Parser
-
Parser
-
-
Methodendetails
-
newEventHandler
-
get_next_free_rule_index
protected long get_next_free_rule_index() -
readGrammar
-
extract_text_based_rules
-
compute_rule_key
protected long compute_rule_key(long rule_index_1, long rule_index_2) -
is_terminal
-
de_escape
-
add_terminal
-
top_nodes
-
collect_one_backwards
-
collect_backwards
-
collect_backwards
-
raise_events
-
fill_tree
-
parse
Parse the given text, constructing the output object of type T using the provided parser event handler.- Parameter:
textToParse- the text to parse.parserEventHandler- the parser event handler to process events created by the parser.- Gibt zurück:
- the parsed object of type T if successful, otherwise an exception will be thrown.
- Löst aus:
LipidParsingException
-
parse
public T parse(String textToParse, BaseParserEventHandler<T> parserEventHandler, boolean throwError) Parse the given text, constructing the output object of type T using the provided parser event handler.Allows the user to specify, if exceptions should be thrown on errors.- Parameter:
textToParse- the text to parse.parserEventHandler- the parser event handler to process events created by the parser.throwError- if true, throws exception if parsing was not successful.- Gibt zurück:
- the parsed object of type T if successful, otherwise
null, if throwError isfalse.
-
parse_regular
protected Optional<Parser<T>.ParsingErrors> parse_regular(String text_to_parse, BaseParserEventHandler<T> parserEventHandler)
-