com.google.clearsilver.jsilver.data
Class NewHdfParser
java.lang.Object
com.google.clearsilver.jsilver.data.NewHdfParser
- All Implemented Interfaces:
- Parser
public class NewHdfParser
- extends Object
- implements Parser
Parser for HDF based on the following grammar by Brandon Long.
COMMAND := (INCLUDE | COMMENT | HDF_SET | HDF_DESCEND | HDF_ASCEND ) INCLUDE := #include
"FILENAME" EOL COMMENT := # .* EOL HDF_DESCEND := HDF_NAME_ATTRS { EOL HDF_ASCEND := } EOL
HDF_SET := (HDF_ASSIGN | HDF_MULTILINE_ASSIGN | HDF_COPY | HDF_LINK) HDF_ASSIGN := HDF_NAME_ATTRS
= .* EOL HDF_MULTILINE_ASSIGN := HDF_NAME_ATTRS << EOM_MARKER EOL (.* EOL)* EOM_MARKER EOL
HDF_COPY := HDF_NAME_ATTRS := HDF_NAME EOL HDF_LINK := HDF_NAME_ATTRS : HDF_NAME EOL
HDF_NAME_ATTRS := (HDF_NAME | HDF_NAME [HDF_ATTRS]) HDF_ATTRS := (HDF_ATTR | HDF_ATTR, HDF_ATTRS)
HDF_ATTR := (HDF_ATTR_KEY | HDF_ATTR_KEY = [^\s,\]]+ | HDF_ATTR_KEY = DQUOTED_STRING)
HDF_ATTR_KEY := [0-9a-zA-Z]+ DQUOTED_STRING := "([^\\"]|\\[ntr]|\\.)*" HDF_NAME := (HDF_SUB_NAME
| HDF_SUB_NAME\.HDF_NAME) HDF_SUB_NAME := [0-9a-zA-Z_]+ EOM_MARKER := \S.*\S EOL := \n
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NewHdfParser
public NewHdfParser(StringInternStrategy internPool)
- Constructor for
NewHdfParser
.
- Parameters:
internPool
- - StringInternStrategy
instance used to optimize the HDF parsing.
newFactory
public static ParserFactory newFactory(StringInternStrategy stringInternStrategy)
- Creates a
ParserFactory
instance.
Provided stringInternStrategy
instance will be used by shared all Parser
objects created by the factory and used to optimize the HDF parsing process by reusing the
String for keys and values.
- Parameters:
stringInternStrategy
- - StringInternStrategy
instance used to optimize the HDF
parsing.
- Returns:
- an instance of
ParserFactory
implementation.
parse
public void parse(Reader reader,
Data output,
Parser.ErrorHandler errorHandler,
ResourceLoader resourceLoader,
String dataFileName,
boolean ignoreAttributes)
throws IOException
- Description copied from interface:
Parser
- Reads in a stream of characters and parses data from it, putting it into the given Data object.
- Specified by:
parse
in interface Parser
- Parameters:
reader
- Reader used to read in the formatted data.output
- Data object that the read data structure will be dumped into.errorHandler
- Error callback to be called on any error.resourceLoader
- ResourceLoader to use to read in included files.dataFileName
- Name of a file that is read with reader. It is needed for the purpose of
handling include loops and error messages.ignoreAttributes
- whether to store parsed HDF attributes in the Data object or not.
- Throws:
IOException
- when errors occur reading input.
Copyright © 2010-2012 Google. All Rights Reserved.