org.millscript.millscript.syntax
Class InfixSyntax
java.lang.Object
org.millscript.millscript.syntax.Syntax
org.millscript.millscript.syntax.PostfixSyntax
org.millscript.millscript.syntax.InfixSyntax
- All Implemented Interfaces:
- PostfixSyntaxInterface
public class InfixSyntax
- extends PostfixSyntax
This class represents infix syntax, a variant of postfix syntax. This is used
in situations where the syntax sits 'in'-between its arguments and maps to a
function call. The syntax follows the form:
<expr> S <expr>
which is very similar to the SimplePostfixSyntax, but it maps to a
function call(actually an ApplyExpr). e.g. it's almost the equivalent
of writing:
S( <expr>, <expr> )
To implement a new piece of infix syntax simply requires that you create a
new function and map it to the relevant symbol in the Parser.
- See Also:
ApplyExpr
|
Method Summary |
ApplyExpr |
postfix(java.lang.String sym,
int prec,
Expr lhs,
Parser parser)
Parse the syntax for the specified symbol, using the specified
Parser. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InfixSyntax
public InfixSyntax()
postfix
public ApplyExpr postfix(java.lang.String sym,
int prec,
Expr lhs,
Parser parser)
- Description copied from interface:
PostfixSyntaxInterface
- Parse the syntax for the specified symbol, using the specified
Parser. The symbol is specified because different symbols
may share the same syntax, but result in slightly different expressions.
The Parser is supplied as the source to parse from. As this
is postfix syntax, we are also supplied the expression on the left hand
side of the symbol along with the current precedence we should parse to.
- Specified by:
postfix in interface PostfixSyntaxInterface- Specified by:
postfix in class PostfixSyntax
- Parameters:
sym - the symbol to parse this syntax forprec - the current precedence we should parse tolhs - the expression on the left hand side of the specified
symbolparser - Parser to parse from, i.e. the source to parse from
- Returns:
- an expression for this syntax
- See Also:
PostfixSyntaxInterface.postfix(java.lang.String, int, org.millscript.millscript.expr.Expr, org.millscript.millscript.syntax.Parser)
Copyright © 2001-2007 Open World Ltd. All Rights Reserved.