org.millscript.millscript.syntax
Class IndexSyntax

java.lang.Object
  extended by org.millscript.millscript.syntax.Syntax
      extended by org.millscript.millscript.syntax.PostfixSyntax
          extended by org.millscript.millscript.syntax.IndexSyntax
All Implemented Interfaces:
PostfixSyntaxInterface

public final class IndexSyntax
extends PostfixSyntax

This class implements index syntax. The index operator [ is used for indexing lists and maps, or objects that can be viewed as a list. The index operator is also used for subranging a list, or an object that can be viewed as a list.

Indexing:
<expr>[ <expr> ]
Subranging:
<expr>[ <expr> .. <expr> ]

In the case of indexing, the left hand side expression should return a single result, which must be a list, map, or an object with a list view. The right hand expression should return a single result, which is used to index the left hand side. e.g. in the case where the left hand side is a list, the right hand side should be a number. in the case where the left hand side is a map, the right hand side should be any object which is a valid key for the map.

In the case of subranging, the left hand side expression should return a single result, which must be a list or an object with a list view. The right hand side expressions should both return a single result, which is used to subrage the left hand side. e.g. in the case where the left hand side is a list, both right hand side expressions should be valid indicies.

See Also:
IndexExpr, SubrangeExpr

Constructor Summary
IndexSyntax()
           
 
Method Summary
 Expr 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 org.millscript.millscript.syntax.PostfixSyntax
getPrecedence, setPrec
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexSyntax

public IndexSyntax()
Method Detail

postfix

public Expr 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 for
prec - the current precedence we should parse to
lhs - the expression on the left hand side of the specified symbol
parser - 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.