|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.me.nxg.unity.UnitParser
public class UnitParser
A parser for unit strings. The parser will parse a single string.
There are a number of different parsers available,
enumerated in Syntax
.
See the uk.me.nxg.unity
package documentation
for fuller discussion of the grammars.
Nested Class Summary | |
---|---|
static class |
UnitParser.Lexeme
A single lexeme. |
Constructor Summary | |
---|---|
UnitParser(Syntax syntax,
String unitString)
Create a new unit parser. |
Method Summary | |
---|---|
UnitParser.Lexeme |
getLexeme()
Return successive lexemes from the input. |
UnitExpr |
getParsed()
Retrieve the parsed result |
static boolean |
isKnownParser(String parser)
Indicates whether the argument is the name of a known parser. |
static void |
main(String[] args)
The library main program, for exploring the library's functionality. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnitParser(Syntax syntax, String unitString) throws UnitParserException
Syntax.values()
, or can alternatively be specified using the
values enumerated in Syntax
.
syntax
- one of the known syntaxesunitString
- the string to be parsed
UnitParserException
- if no parser can be created (typically because the required syntax is unknown)Method Detail |
---|
public UnitExpr getParsed() throws UnitParserException
UnitParserException
- if the parse failspublic static boolean isKnownParser(String parser)
parser
- the string name of a parser (eg "fits")
Syntax
public UnitParser.Lexeme getLexeme()
public static void main(String[] args)
Usage:
UnitParser [-isyntax] [-osyntax] [-v] unit-expression
Parse and redisplay the string expression given as argument.
The -i
and -o
flags specify the
input and output syntaxes.
UnitParser -S
List the set of available syntaxes
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |