Package org.jparsec
Class Operators
java.lang.Object
org.jparsec.Operators
Helper class for creating parsers and lexers for operators.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
A suite is a list of overlapping operators, where some operators are prefixes of other operators.private static final class
A list of suites in the reverse order of the suites. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Lexicon
lexicon
(Collection<String> operatorNames) Gets aLexicon
instance withTokens.reserved(String)
as each operator's value and a lexer that strives to try the shortest operator first.(package private) static String[]
Sortsnames
into a new array by putting short string first, unless a shorter string is a prefix of a longer string, in which case, the longer string is before the prefix string.
-
Field Details
-
LONGER_STRING_FIRST
-
-
Constructor Details
-
Operators
Operators()
-
-
Method Details
-
lexicon
Gets aLexicon
instance withTokens.reserved(String)
as each operator's value and a lexer that strives to try the shortest operator first.Safely speaking, we can always start from the longest operator and falls back to shorter ones. Yet shorter operators are more often used than longer ones and the scanning of them is faster. However, scanning shorter operators first has the chance that a "==" is mistakenly scanned as "=" followed by another "=". In order to avoid this, we analyze the prefix relationship and make sure that prefixes are scanned after prefixes.
-
sort
Sortsnames
into a new array by putting short string first, unless a shorter string is a prefix of a longer string, in which case, the longer string is before the prefix string.
-