public class WhileyFileParser extends Object
| Constructor and Description |
|---|
WhileyFileParser(wyfs.lang.Path.Entry<WhileyFile> entry,
List<WhileyFileLexer.Token> tokens) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
mustParseAsMixedType() |
wyal.lang.WyalFile.Type |
parseDefiniteType(wyc.io.WhileyFileParser.EnclosingScope scope)
Attempt to parse something which maybe a type, or an expression.
|
List<Expr> |
parseExpressions(WhileyFile wf,
wyc.io.WhileyFileParser.EnclosingScope scope,
boolean terminated)
Parse a "multi-expression"; that is, a sequence of one or more
expressions separated by comma's
|
wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Identifier> |
parseOptionalContextLifetimes(wyc.io.WhileyFileParser.EnclosingScope scope) |
wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Identifier> |
parseOptionalLifetimeParameters(wyc.io.WhileyFileParser.EnclosingScope scope)
Attention: Enters the lifetime names to the passed scope!
|
WhileyFile.Parameter |
parseOptionalParameter(WhileyFile wf,
wyc.io.WhileyFileParser.EnclosingScope scope) |
List<WhileyFile.Parameter> |
parseOptionalParameters(WhileyFile wf,
wyc.io.WhileyFileParser.EnclosingScope scope) |
wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Type> |
parseOptionalParameterTypes(wyc.io.WhileyFileParser.EnclosingScope scope) |
List<WhileyFile.Parameter> |
parseParameters(WhileyFile wf,
wyc.io.WhileyFileParser.EnclosingScope scope) |
wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Type> |
parseParameterTypes(wyc.io.WhileyFileParser.EnclosingScope scope) |
protected List<Constant> |
parseString(String v)
Parse a string constant whilst interpreting all escape characters.
|
void |
parseTypeDeclaration(WhileyFile wf,
List<Modifier> modifiers)
Parse a type declaration in a Whiley source file, which has the form:
|
WhileyFile |
read()
Read a
WhileyFile from the token stream. |
public WhileyFileParser(wyfs.lang.Path.Entry<WhileyFile> entry, List<WhileyFileLexer.Token> tokens)
public WhileyFile read()
WhileyFile from the token stream. If the stream is
invalid in some way (e.g. contains a syntax error, etc) then a
SyntaxError is thrown.public List<WhileyFile.Parameter> parseParameters(WhileyFile wf, wyc.io.WhileyFileParser.EnclosingScope scope)
public List<WhileyFile.Parameter> parseOptionalParameters(WhileyFile wf, wyc.io.WhileyFileParser.EnclosingScope scope)
public WhileyFile.Parameter parseOptionalParameter(WhileyFile wf, wyc.io.WhileyFileParser.EnclosingScope scope)
public void parseTypeDeclaration(WhileyFile wf, List<Modifier> modifiers)
"type" Identifier "is" TypePattern ("where" Expr)*
Here, the type pattern specifies a type which may additionally be adorned
with variable names. The "where" clause is optional and is often referred
to as the type's "constraint". Variables defined within the type pattern
may be used within this constraint expressions. A simple example to
illustrate is:
type nat is (int x) where x >= 0Here, we are defining a constrained type called
nat
which represents the set of natural numbers (i.e the non-negative
integers). Type declarations may also have modifiers, such as
public and private.wf - --- The Whiley file in which this declaration is defined.modifiers - --- The list of modifiers for this declaration (which were
already parsed before this method was called).WhileyFile.Typepublic List<Expr> parseExpressions(WhileyFile wf, wyc.io.WhileyFileParser.EnclosingScope scope, boolean terminated)
wf - The enclosing WhileyFile being constructed. This is necessary
to construct some nested declarations (e.g. parameters for
lambdas)scope - The enclosing scope for this statement, which determines the
set of visible (i.e. declared) variables and also the current
indentation level.terminated - This indicates that the expression is known to be terminated
(or not). An expression that's known to be terminated is one
which is guaranteed to be followed by something. This is
important because it means that we can ignore any newline
characters encountered in parsing this expression, and that
we'll never overrun the end of the expression (i.e. because
there's guaranteed to be something which terminates this
expression). A classic situation where terminated is true is
when parsing an expression surrounded in braces. In such case,
we know the right-brace will always terminate this expression.public wyal.lang.WyalFile.Type parseDefiniteType(wyc.io.WhileyFileParser.EnclosingScope scope)
public wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Type> parseOptionalParameterTypes(wyc.io.WhileyFileParser.EnclosingScope scope)
public wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Type> parseParameterTypes(wyc.io.WhileyFileParser.EnclosingScope scope)
public wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Identifier> parseOptionalLifetimeParameters(wyc.io.WhileyFileParser.EnclosingScope scope)
scope - public wyal.lang.WyalFile.Tuple<wyal.lang.WyalFile.Identifier> parseOptionalContextLifetimes(wyc.io.WhileyFileParser.EnclosingScope scope)
scope - public boolean mustParseAsMixedType()
Copyright © 2017. All rights reserved.