org.millscript.millscript.syntax
Class ConfigurationParserImpl

java.lang.Object
  extended by org.millscript.millscript.syntax.TokenizerImpl
      extended by org.millscript.millscript.syntax.ConfigurationParserImpl
All Implemented Interfaces:
org.millscript.commons.alert.AlertOrigin, Parser, Tokenizer
Direct Known Subclasses:
ParserImpl

public class ConfigurationParserImpl
extends TokenizerImpl
implements Parser

This class implements the MillScript parser for use with configuration files. As such it is actually the complete parser implementation but it excludes nearly all syntax entries. The only syntax this parser understands is "(", "," and ")".


Field Summary
 
Fields inherited from class org.millscript.millscript.syntax.TokenizerImpl
config, interpolationMap
 
Fields inherited from interface org.millscript.millscript.syntax.Parser
ARITH_PREC, COMMA_PREC, COMMA_PREC1, LOW_PREC, NOT_PREC, RELOP_PREC, TIGHT_PREC
 
Constructor Summary
ConfigurationParserImpl(java.lang.String origin, java.io.Reader r, boolean eolc, Configuration c)
          Constructs a new ParserImpl with the specified origin, source, interactive prompt and end of line comment status.
 
Method Summary
 NameExpr getEnclosingClass()
          Returns the enclosing class for this parser.
 Expr makeInterpolatedExpr()
          Returns the current string, as an application of the format function with the current interpolation map values as arguments.
protected static void put(java.lang.String s, Syntax t)
          Convenience method for inserting entries in the symbol table.
 java.lang.String readAttributeName()
          Reads the next token from the source as an attribute name and returns it.
 Expr readBlock()
          Reads a sequence of expressions from the source as a Block.
 Expr readBlockTo(java.lang.String sym)
          Reads a sequence of expressions, followed by the specified symbol, from the source as a Block.
 Expr readExpr()
          Reads the next expression from the source.
 Expr readExprComma()
          Reads the next expression from the source at the COMMA_PREC1 precedence level.
 Expr readExprPrec(int prec)
          Reads the next expression from the source at the specified precedence level.
 Expr readExprTo(java.lang.String sym)
          Reads the next expression from the source, which must be followed by the specified symbol.
 NameExpr readName()
          Reads the next token from the source as a name and returns a name expression for it.
 Expr readOptExpr()
          Reads the optional next expression from the source.
 Expr readOptExprPrec(int prec)
          Reads the optional next expression from the source at the specified precedence level.
 Expr readOptPrimary()
          Reads the next token from the source as the optional primary expression in a potential sequence of expressions.
 Expr readPrimary()
          Reads the next token from the source as the primary expression in a potential sequence of expressions.
 Expr readStmnts()
          Reads a sequence of expressions from the source.
 Expr readStmntsTo(java.lang.String sym)
          Reads a sequence of expressions from the source, which must be followed by the specified symbol.
 java.lang.String readSymbol()
          Reads the next token from the source as a symbol and returns it.
 java.lang.String readTagName()
          Reads the next token from the source as a tag name and returns it.
 
Methods inherited from class org.millscript.millscript.syntax.TokenizerImpl
checkWhere, dropToken, getAttributeName, getErrorString, getInt, getLineNumber, getName, getOrigin, getQuoteChar, getString, getStringNoQuotes, getStringNoQuotes, getTagName, makePattern, markReader, mustRead, nextToken, peekRead, peekToken, resetReader, setContext, setLineNumber, setOrigin, setWhere, tryRead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.millscript.millscript.syntax.Tokenizer
checkWhere, dropToken, getAttributeName, getErrorString, getInt, getLineNumber, getName, getOrigin, getQuoteChar, getString, getStringNoQuotes, getStringNoQuotes, getTagName, makePattern, markReader, mustRead, nextToken, peekRead, peekToken, resetReader, setWhere, tryRead
 
Methods inherited from interface org.millscript.commons.alert.AlertOrigin
setContext, setLineNumber, setOrigin
 

Constructor Detail

ConfigurationParserImpl

public ConfigurationParserImpl(java.lang.String origin,
                               java.io.Reader r,
                               boolean eolc,
                               Configuration c)
Constructs a new ParserImpl with the specified origin, source, interactive prompt and end of line comment status.

Parameters:
origin - the origin message for this tokenizer
r - the character source to tokenize
eolc - flag indicating if end of line comments are supported
c - the configuration
Method Detail

getEnclosingClass

public NameExpr getEnclosingClass()
Description copied from interface: Parser
Returns the enclosing class for this parser.

Specified by:
getEnclosingClass in interface Parser
Returns:
a NameExpr for the enclosing class
See Also:
Parser.getEnclosingClass()

makeInterpolatedExpr

public Expr makeInterpolatedExpr()
Description copied from interface: Parser
Returns the current string, as an application of the format function with the current interpolation map values as arguments. The values in the interpolation map will be parsed into expressions.

Specified by:
makeInterpolatedExpr in interface Parser
Returns:
an ApplyExpr, applying the format function to format the current string
See Also:
Parser.makeInterpolatedExpr()

put

protected static void put(java.lang.String s,
                          Syntax t)
Convenience method for inserting entries in the symbol table.

Parameters:
s - symbol
t - Syntax for symbol

readAttributeName

public java.lang.String readAttributeName()
Description copied from interface: Parser
Reads the next token from the source as an attribute name and returns it. An alert will be generated if the next token is not a name.

Specified by:
readAttributeName in interface Parser
Returns:
a String containing a tag name
See Also:
Parser.readAttributeName()

readBlock

public Expr readBlock()
Description copied from interface: Parser
Reads a sequence of expressions from the source as a Block.

Specified by:
readBlock in interface Parser
Returns:
a Block wrapping the sequence of expressions read
See Also:
Parser.readBlock()

readBlockTo

public Expr readBlockTo(java.lang.String sym)
Description copied from interface: Parser
Reads a sequence of expressions, followed by the specified symbol, from the source as a Block.

Specified by:
readBlockTo in interface Parser
Parameters:
sym - the symbol which must follow the block
Returns:
a Block wrapping the sequence of expressions read
See Also:
Parser.readBlockTo(java.lang.String)

readExpr

public Expr readExpr()
Description copied from interface: Parser
Reads the next expression from the source.

Specified by:
readExpr in interface Parser
Returns:
an Expr for the next token in the source
See Also:
Parser.readExpr()

readExprComma

public Expr readExprComma()
Description copied from interface: Parser
Reads the next expression from the source at the COMMA_PREC1 precedence level. Hence this will read up to the next comma.

Specified by:
readExprComma in interface Parser
Returns:
an Expr for the next token in the source
See Also:
Parser.readExprComma()

readExprPrec

public Expr readExprPrec(int prec)
Description copied from interface: Parser
Reads the next expression from the source at the specified precedence level.

Specified by:
readExprPrec in interface Parser
Parameters:
prec - the precedence level to read the next expression at
Returns:
an Expr for the next token in the source
See Also:
Parser.readExprPrec(int)

readExprTo

public Expr readExprTo(java.lang.String sym)
Description copied from interface: Parser
Reads the next expression from the source, which must be followed by the specified symbol.

Specified by:
readExprTo in interface Parser
Parameters:
sym - the symbol which must follow the expression
Returns:
an Expr for the next token in the source
See Also:
Parser.readExprTo(java.lang.String)

readName

public NameExpr readName()
Description copied from interface: Parser
Reads the next token from the source as a name and returns a name expression for it. A name is a symbol that is not a keyword. An alert will be generated if the next token is a built in identifier.

Specified by:
readName in interface Parser
Returns:
a NameExpr for the next token
See Also:
Parser.readName()

readOptExpr

public Expr readOptExpr()
Description copied from interface: Parser
Reads the optional next expression from the source. Optional means that there doesn't have to be another expression in the source.

Specified by:
readOptExpr in interface Parser
Returns:
an Expr for the next token in the source
See Also:
Parser.readOptExpr()

readOptExprPrec

public Expr readOptExprPrec(int prec)
Description copied from interface: Parser
Reads the optional next expression from the source at the specified precedence level. Optional means that there doesn't have to be another expression in the source.

Specified by:
readOptExprPrec in interface Parser
Parameters:
prec - the precedence level to read the next expression at
Returns:
an Expr for the next token in the source
See Also:
Parser.readOptExprPrec(int)

readOptPrimary

public Expr readOptPrimary()
Description copied from interface: Parser
Reads the next token from the source as the optional primary expression in a potential sequence of expressions.

Specified by:
readOptPrimary in interface Parser
Returns:
an Expr for the next token in the source
See Also:
Parser.readOptPrimary()

readPrimary

public Expr readPrimary()
Description copied from interface: Parser
Reads the next token from the source as the primary expression in a potential sequence of expressions.

Specified by:
readPrimary in interface Parser
Returns:
an Expr for the next token in the source
See Also:
Parser.readPrimary()

readStmnts

public Expr readStmnts()
Description copied from interface: Parser
Reads a sequence of expressions from the source. The sequence of expressions are wrapped as a comma expression. This method will read up to the end of file, or a built-in keyword.

Specified by:
readStmnts in interface Parser
Returns:
an Expr for the sequence of expressions read
See Also:
Parser.readStmnts()

readStmntsTo

public Expr readStmntsTo(java.lang.String sym)
Description copied from interface: Parser
Reads a sequence of expressions from the source, which must be followed by the specified symbol.

Specified by:
readStmntsTo in interface Parser
Parameters:
sym - the symbol which must follow the statements
Returns:
an Expr for the sequence of expressions read
See Also:
Parser.readStmntsTo(java.lang.String)

readSymbol

public java.lang.String readSymbol()
Description copied from interface: Parser
Reads the next token from the source as a symbol and returns it. An alert will be generated if the next token is not a name.

Specified by:
readSymbol in interface Parser
Returns:
a String containing the next symbol
See Also:
Parser.readSymbol()

readTagName

public java.lang.String readTagName()
Description copied from interface: Parser
Reads the next token from the source as a tag name and returns it. An alert will be generated if the next token is not a name.

Specified by:
readTagName in interface Parser
Returns:
a String containing a tag name
See Also:
Parser.readTagName()


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.