Package nz.org.riskscape.rl.ast
Class StructDeclaration
java.lang.Object
nz.org.riskscape.rl.ast.StructDeclaration
- All Implemented Interfaces:
Expression
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionStructDeclaration
(List<StructDeclaration.Member> members, Optional<Pair<Token, Token>> boundary) -
Method Summary
Modifier and TypeMethodDescription<T,
R> R accept
(ExpressionVisitor<T, R> visitor, T data) static StructDeclaration.Member
anonMember
(Expression expression) protected void
appendSource
(StringBuilder appendTo) Implementers extend this to append their source to the given string builder.protected boolean
boolean
getMember
(int index) Shortcut forgetMembers().get(index)
int
hashCode()
static StructDeclaration.Member
jsonStyleMember
(String ident, Expression expression) Returns a json style (foo: bar) struct memberstatic StructDeclaration.Member
jsonStyleMember
(Token ident, Expression expression) Returns a json style (foo: bar) struct memberstatic StructDeclaration.Member
selectAllMember
(Token asterisk) Returns a select-all ({*}) struct memberstatic StructDeclaration.Member
sqlStyleMember
(Token ident, Expression expression, Token as) Returns an sql style (bar as foo) struct memberfinal String
toSource()
final String
toString()
withNewMembers
(List<StructDeclaration.Member> newMembers, Optional<Pair<Token, Token>> newBoundary) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nz.org.riskscape.rl.ast.Expression
isA
-
Constructor Details
-
StructDeclaration
-
-
Method Details
-
anonMember
- Returns:
- an anonymous attribute declaration wrapping the given expression.
-
jsonStyleMember
Returns a json style (foo: bar) struct member
-
jsonStyleMember
Returns a json style (foo: bar) struct member
-
sqlStyleMember
Returns an sql style (bar as foo) struct member
-
selectAllMember
Returns a select-all ({*}) struct member
-
appendSource
Implementers extend this to append their source to the given string builder. Done via string builder to encourage a more efficient implementation than is possible with concatenating multiple toString calls that typically contruct a string builder anyway.
-
accept
-
getMember
Shortcut for
getMembers().get(index)
- Returns:
- the AttrDeclaration at the given zero-based index
- Throws:
IndexOutOfBoundsException
- if the index is < 0 or > size
-
withNewMembers
public StructDeclaration withNewMembers(List<StructDeclaration.Member> newMembers, Optional<Pair<Token, Token>> newBoundary) -
equals
-
canEqual
-
hashCode
public int hashCode() -
getMembers
-
getBoundary
- Returns:
- a pair of tokens that represent the start and end of this expression, to be used when giving users information about where errors have occurred. If the expression has been rebuilt then the boundary may be empty or it may be from the original expression. Intended for use in problems to trace errors back to their source.
-
toString
-
toSource
- Specified by:
toSource
in interfaceExpression
- Returns:
- a normalized version of the AST that can be parsed to be exactly the same AST as this
-