| 1 | /******************************************************************************* |
|---|
| 2 | Copyright 2009 Sun Microsystems, Inc., |
|---|
| 3 | 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
|---|
| 4 | All rights reserved. |
|---|
| 5 | |
|---|
| 6 | U.S. Government Rights - Commercial software. |
|---|
| 7 | Government users are subject to the Sun Microsystems, Inc. standard |
|---|
| 8 | license agreement and applicable provisions of the FAR and its supplements. |
|---|
| 9 | |
|---|
| 10 | Use is subject to license terms. |
|---|
| 11 | |
|---|
| 12 | This distribution may include materials developed by third parties. |
|---|
| 13 | |
|---|
| 14 | Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered |
|---|
| 15 | trademarks of Sun Microsystems, Inc. in the U.S. and other countries. |
|---|
| 16 | ******************************************************************************/ |
|---|
| 17 | |
|---|
| 18 | // REMINDER: If you modify this file, you probably ought to be |
|---|
| 19 | // changing ExprFactory.makeInParentheses as well. |
|---|
| 20 | |
|---|
| 21 | // Please do not name any nodes all capital letters. This file is used to autogenerate |
|---|
| 22 | // Library/FortressAst.fsi and fortress traits cannot have all capital letters. |
|---|
| 23 | |
|---|
| 24 | generateEmptyConstructor yes; // for reflective object creation |
|---|
| 25 | visitMethod accept; |
|---|
| 26 | visitorMethodPrefix for; |
|---|
| 27 | addGetterPrefixes yes; |
|---|
| 28 | usePLT yes; |
|---|
| 29 | tabSize 4; |
|---|
| 30 | allowNulls no; |
|---|
| 31 | generateToString no; |
|---|
| 32 | generateEquals yes; |
|---|
| 33 | generateSerializers yes; |
|---|
| 34 | generateRecursiveVisitors no; |
|---|
| 35 | customClassPath ../build; |
|---|
| 36 | |
|---|
| 37 | /* order matters here */ |
|---|
| 38 | customGenerator com.sun.fortress.astgen.ScalaAstGenerator; |
|---|
| 39 | customGenerator com.sun.fortress.astgen.DepthFirstVisitorGenerator; |
|---|
| 40 | customGenerator com.sun.fortress.astgen.CollectingVisitorGenerator; |
|---|
| 41 | customGenerator com.sun.fortress.astgen.TemplateDepthFirstVisitorGenerator; |
|---|
| 42 | |
|---|
| 43 | customGenerator com.sun.fortress.astgen.DepthFirstVoidVisitorGenerator; |
|---|
| 44 | customGenerator com.sun.fortress.astgen.TemplateDepthFirstVoidVisitorGenerator; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | customPreprocessor com.sun.fortress.astgen.TransformationNodeCreator; |
|---|
| 48 | customPreprocessor com.sun.fortress.astgen.EllipsesNodeCreator; |
|---|
| 49 | customPreprocessor com.sun.fortress.astgen.TemplateGapNodeCreator; |
|---|
| 50 | customGenerator com.sun.fortress.astgen.UpdateVisitorGenerator; |
|---|
| 51 | customGenerator com.sun.fortress.astgen.TemplateVisitorGenerator; |
|---|
| 52 | |
|---|
| 53 | customGenerator com.sun.fortress.astgen.SingleSpanConstructorGenerator; |
|---|
| 54 | |
|---|
| 55 | customGenerator com.sun.fortress.astgen.FortressAstGenerator; |
|---|
| 56 | |
|---|
| 57 | package com.sun.fortress.nodes; |
|---|
| 58 | import java.lang.String; |
|---|
| 59 | import java.math.BigInteger; |
|---|
| 60 | import java.io.Writer; |
|---|
| 61 | import java.util.Collections; |
|---|
| 62 | import java.util.List; |
|---|
| 63 | import java.util.Map; |
|---|
| 64 | import java.util.ArrayList; |
|---|
| 65 | import java.util.LinkedList; |
|---|
| 66 | import com.sun.fortress.nodes_util.*; |
|---|
| 67 | import com.sun.fortress.parser_util.*; |
|---|
| 68 | import com.sun.fortress.parser_util.precedence_opexpr.*; |
|---|
| 69 | import com.sun.fortress.useful.*; |
|---|
| 70 | import edu.rice.cs.plt.tuple.Option; |
|---|
| 71 | |
|---|
| 72 | begin ast; |
|---|
| 73 | |
|---|
| 74 | /** |
|---|
| 75 | * top-level interface |
|---|
| 76 | */ |
|---|
| 77 | interface Node() extends HasAt; |
|---|
| 78 | /** |
|---|
| 79 | * top-level node interface |
|---|
| 80 | */ |
|---|
| 81 | interface ASTNode(ASTNodeInfo info); |
|---|
| 82 | /** |
|---|
| 83 | * with static parameters |
|---|
| 84 | * implemented by trait, object, and function declarations and |
|---|
| 85 | * object expressions in components or APIs |
|---|
| 86 | */ |
|---|
| 87 | interface Generic(GenericHeader header); |
|---|
| 88 | /** |
|---|
| 89 | * with static parameters, value parameters, and declarations |
|---|
| 90 | * implemented by object declaration and |
|---|
| 91 | * object expressions in components or APIs |
|---|
| 92 | */ |
|---|
| 93 | interface ObjectConstructor(TraitTypeHeader header, |
|---|
| 94 | Option<List<Param>> params); |
|---|
| 95 | /** |
|---|
| 96 | * top-level node abstract class |
|---|
| 97 | */ |
|---|
| 98 | root abstract AbstractNode(ASTNodeInfo info) extends UIDObject; |
|---|
| 99 | /** |
|---|
| 100 | * compilation unit declaration |
|---|
| 101 | * CompilationUnit ::= Component | Api |
|---|
| 102 | */ |
|---|
| 103 | abstract CompilationUnit(APIName name, List<Import> imports, |
|---|
| 104 | List<Decl> decls, List<APIName> comprises); |
|---|
| 105 | /** |
|---|
| 106 | * component declaration |
|---|
| 107 | * Component ::= native? component APIName Imports? Exports Decls? end |
|---|
| 108 | * Export ::= export APINames |
|---|
| 109 | * e.g.) component Hello |
|---|
| 110 | * export Executable |
|---|
| 111 | * run(args:String...) = print "Hello, World!\n" |
|---|
| 112 | * end |
|---|
| 113 | */ |
|---|
| 114 | Component(boolean _native, List<APIName> exports); |
|---|
| 115 | /** |
|---|
| 116 | * API declaration |
|---|
| 117 | * Api ::= api APIName Imports? AbsDecls? end |
|---|
| 118 | * e.g.) api Executable |
|---|
| 119 | * run(args:String...):() |
|---|
| 120 | * end |
|---|
| 121 | */ |
|---|
| 122 | Api(); |
|---|
| 123 | /** |
|---|
| 124 | * import statement |
|---|
| 125 | * Import ::= import ImportedNames | import api AliasedAPINames |
|---|
| 126 | */ |
|---|
| 127 | abstract Import(Option<String> foreignLanguage); |
|---|
| 128 | /** |
|---|
| 129 | * ImportedNames ::= APIName . {...} (except SimpleNames)? |
|---|
| 130 | * | APIName . { AliasedSimpleNameList (, ...)? } |
|---|
| 131 | * | QualifiedName (as Id)? |
|---|
| 132 | */ |
|---|
| 133 | abstract ImportedNames(APIName apiName); |
|---|
| 134 | /** |
|---|
| 135 | * Names must be unqualified. |
|---|
| 136 | * e.g.) import Set.{...} except {opr UNION, union} |
|---|
| 137 | */ |
|---|
| 138 | ImportStar(List<IdOrOpOrAnonymousName> exceptNames); |
|---|
| 139 | /** |
|---|
| 140 | * e.g.) import Set.{empty, union} |
|---|
| 141 | */ |
|---|
| 142 | ImportNames(List<AliasedSimpleName> aliasedNames); |
|---|
| 143 | /** |
|---|
| 144 | * e.g.) import api {Set, Map, List} |
|---|
| 145 | */ |
|---|
| 146 | ImportApi(List<AliasedAPIName> apis); |
|---|
| 147 | /** |
|---|
| 148 | * aliased simple name used in import statements |
|---|
| 149 | * AliasedSimpleName ::= Id (as Id)? |
|---|
| 150 | * | opr Op (as Op)? |
|---|
| 151 | * | opr EncloserPair (as EncloserPair)? |
|---|
| 152 | * EncloserPair ::= (LeftEncloser | Encloser) (RightEncloser | Encloser) |
|---|
| 153 | * e.g.) longComplexName as shortName |
|---|
| 154 | * Names and aliases must be unqualified. |
|---|
| 155 | */ |
|---|
| 156 | AliasedSimpleName(IdOrOpOrAnonymousName name, |
|---|
| 157 | Option<IdOrOpOrAnonymousName> alias); |
|---|
| 158 | /** |
|---|
| 159 | * aliased API name used in import statements |
|---|
| 160 | * AliasedAPIName ::= APIName (as Id)? |
|---|
| 161 | * e.g.) com.sun.fortress.parser.precedence.resolver as precedence_resolver |
|---|
| 162 | * Alias must be unqualified. |
|---|
| 163 | */ |
|---|
| 164 | AliasedAPIName(APIName apiName, Option<Id> alias); |
|---|
| 165 | |
|---|
| 166 | /** Begin Decl nodes *********************************************** */ |
|---|
| 167 | /** |
|---|
| 168 | * declaration in components or APIs |
|---|
| 169 | */ |
|---|
| 170 | abstract Decl(); |
|---|
| 171 | /** |
|---|
| 172 | * trait or object declaration in components or APIs |
|---|
| 173 | * Name must be unqualified. |
|---|
| 174 | * |
|---|
| 175 | * selfType is introduced in r3713; |
|---|
| 176 | * it is initialized by compiler.disambiguator.SelfParamDisambiguator. |
|---|
| 177 | */ |
|---|
| 178 | abstract TraitObjectDecl(TraitTypeHeader header, Option<SelfType> selfType) implements Generic; |
|---|
| 179 | /** |
|---|
| 180 | * trait declaration in components or APIs |
|---|
| 181 | * |
|---|
| 182 | * trait declaration in APIs |
|---|
| 183 | * AbsTraitDecl ::= AbsTraitMods? TraitHeaderFront AbsTraitClauses |
|---|
| 184 | * AbsGoInATrait? end |
|---|
| 185 | * TraitHeaderFront ::= trait Id StaticParams? ExtendsWhere? |
|---|
| 186 | * ExtendsWhere ::= extends TraitTypeWheres |
|---|
| 187 | * AbsTraitClause ::= Excludes | AbsComprises | Where |
|---|
| 188 | * Excludes ::= excludes TraitTypes |
|---|
| 189 | * AbsComprises ::= comprises ComprisingTypes |
|---|
| 190 | * ComprisingTypes ::= TraitType | { ComprisingTypeList } |
|---|
| 191 | * ComprisingTypeList ::= ... |
|---|
| 192 | * | TraitType(, TraitType)*(, ...)? |
|---|
| 193 | * AbsGoInATrait ::= AbsCoercions? AbsGoFrontInATrait AbsGoBackInATrait? |
|---|
| 194 | * | AbsCoercions? AbsGoBackInATrait |
|---|
| 195 | * | AbsCoercions |
|---|
| 196 | * AbsGoesFrontInATrait ::= ApiFldDecl |
|---|
| 197 | * | AbsGetterSetterDecl |
|---|
| 198 | * | PropertyDecl |
|---|
| 199 | * AbsGoesBackInATrait ::= AbsMdDecl |
|---|
| 200 | * | PropertyDecl |
|---|
| 201 | * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} |
|---|
| 202 | * cons(x: alph): List[\alpha\] |
|---|
| 203 | * end |
|---|
| 204 | * |
|---|
| 205 | * trait declaration in components |
|---|
| 206 | * TraitDecl ::= TraitMods? TraitHeaderFront TraitClauses GoInATrait? |
|---|
| 207 | * end |
|---|
| 208 | * TraitClause ::= Excludes | Comprises | Where |
|---|
| 209 | * Comprises ::= comprises TraitTypes |
|---|
| 210 | * GoInATrait ::= Coercions? GoFrontInATrait GoBackInATrait? |
|---|
| 211 | * | Coercions? GoBackInATrait |
|---|
| 212 | * | Coercions |
|---|
| 213 | * GoesFrontInATrait ::= AbsFldDecl |
|---|
| 214 | * | GetterSetterDecl |
|---|
| 215 | * | PropertyDecl |
|---|
| 216 | * GoesBackInATrait ::= MdDecl |
|---|
| 217 | * | PropertyDecl |
|---|
| 218 | * e.g.) trait List[\alpha\] comprises {Cons[\alpha\],Empty[\alpha\]} |
|---|
| 219 | * cons(x: alph): List[\alpha\] = Cons[\alph\](x, self) |
|---|
| 220 | * end |
|---|
| 221 | */ |
|---|
| 222 | TraitDecl(List<BaseType> excludesClause, |
|---|
| 223 | Option<List<NamedType>> comprisesClause, |
|---|
| 224 | boolean comprisesEllipses); |
|---|
| 225 | /** |
|---|
| 226 | * object declaration in components or APIs |
|---|
| 227 | * |
|---|
| 228 | * object declaration in APIs |
|---|
| 229 | * AbsObjectDecl ::= AbsObjectMods? ObjectHeader AbsGoInAnObject? end |
|---|
| 230 | * ObjectHeader ::= object Id StaticParams? ObjectValParam? |
|---|
| 231 | * ExtendsWhere? FnClauses |
|---|
| 232 | * FnClauses ::= Throws? Where? Contract |
|---|
| 233 | * Throws ::= throws MayTraitTypes |
|---|
| 234 | * ObjectValParam ::= ( ObjectParams? ) |
|---|
| 235 | * ObjectParams ::= (ObjectParam ,)* ObjectKeyword(, ObjectKeyword)* |
|---|
| 236 | * | ObjectParam (, ObjectParam)* |
|---|
| 237 | * ObjectKeyword ::= ObjectParam = Expr |
|---|
| 238 | * ObjectParam ::= ParamFldMods? Param |
|---|
| 239 | * | var Param |
|---|
| 240 | * AbsGoInAnObject ::= AbsCoercions? AbsGoFrontInAnObject AbsGoBackInAnObject? |
|---|
| 241 | * | AbsCoercions? AbsGoBackInAnObject |
|---|
| 242 | * | AbsCoercions |
|---|
| 243 | * AbsGoesFrontInAnObject ::= ApiFldDecl |
|---|
| 244 | * | AbsGetterSetterDecl |
|---|
| 245 | * | PropertyDecl |
|---|
| 246 | * AbsGoesBackInAnObject ::= AbsMdDecl |
|---|
| 247 | * | PropertyDecl |
|---|
| 248 | * e.g.) object Empty[\alph\]() extends List[\alpha\] end |
|---|
| 249 | * |
|---|
| 250 | * object declaration in components |
|---|
| 251 | * ObjectDecl ::= ObjectMods? ObjectHeader GoInAnObject? end |
|---|
| 252 | * GoInAnObject ::= Coercions? GoFrontInAnObject GoBackInAnObject? |
|---|
| 253 | * | Coercions? GoBackInAnObject |
|---|
| 254 | * | Coercions |
|---|
| 255 | * GoesFrontInAnObject ::= FldDecl |
|---|
| 256 | * | GetterSetterDecl |
|---|
| 257 | * | PropertyDecl |
|---|
| 258 | * GoesBackInAnObject ::= MdDef |
|---|
| 259 | * | PropertyDecl |
|---|
| 260 | * e.g.) object Empty[\alph\]() extends List[\alpha\] |
|---|
| 261 | * length() = 0 |
|---|
| 262 | * end |
|---|
| 263 | */ |
|---|
| 264 | ObjectDecl(Option<List<Param>> params) |
|---|
| 265 | implements ObjectConstructor; |
|---|
| 266 | /** |
|---|
| 267 | * variable declaration in components or APIs |
|---|
| 268 | * |
|---|
| 269 | * variable declaration in APIs |
|---|
| 270 | * AbsVarDecl ::= AbsVarMods? VarWTypes |
|---|
| 271 | * | AbsVarMods? BindIdOrBindIdTuple : Type ... |
|---|
| 272 | * | AbsVarMods? BindIdOrBindIdTuple : SimpleTupleType |
|---|
| 273 | * VarWTypes ::= VarWType | ( VarWType(, VarWType)+ ) |
|---|
| 274 | * VarWType ::= BindId IsType |
|---|
| 275 | * BindIdOrBindIdTuple ::= BindId |
|---|
| 276 | * | ( BindId , BindIdList ) |
|---|
| 277 | * BindId ::= Id | _ |
|---|
| 278 | * e.g.) var (x, y): ZZ64... |
|---|
| 279 | * |
|---|
| 280 | * variable declaration in components |
|---|
| 281 | * VarDecl ::= VarMods? VarWTypes InitVal |
|---|
| 282 | * | VarMods? BindIdOrBindIdTuple = Expr |
|---|
| 283 | * | VarMods? BindIdOrBindIdTuple : Type ... InitVal |
|---|
| 284 | * | VarMods? BindIdOrBindIdTuple : SimpleTupleType InitVal |
|---|
| 285 | * InitVal ::= (= | :=) Expr |
|---|
| 286 | * e.g.) var (x, y): ZZ64... = (5, 6) |
|---|
| 287 | */ |
|---|
| 288 | VarDecl(List<LValue> lhs, Option<Expr> init); |
|---|
| 289 | /** |
|---|
| 290 | * functional declaration in components or APIs |
|---|
| 291 | * Names must be unqualified. |
|---|
| 292 | * |
|---|
| 293 | * functional declaration in components or APIs |
|---|
| 294 | * AbsFnDecl ::= AbsFnMods? FnHeaderFront FnHeaderClause |
|---|
| 295 | * | FnSig |
|---|
| 296 | * FnSig ::= SimpleName : ArrowType |
|---|
| 297 | * FnHeaderFront ::= NamedFnHeaderFront |
|---|
| 298 | * | OpHeaderFront |
|---|
| 299 | * NamedFnHeaderFront ::= Id StaticParams? ValParam |
|---|
| 300 | * OpHeaderFront ::= opr StaticParams? BIG? (LeftEncloser | Encloser) |
|---|
| 301 | * Params (RightEncloser | Encloser) |
|---|
| 302 | * | opr StaticParams? ValParam (Op | ExponentOp) |
|---|
| 303 | * | opr BIG? (Op | ^ | Encloser) StaticParams? ValParam |
|---|
| 304 | * FnHeaderClause ::= IsType? FnClauses |
|---|
| 305 | * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause |
|---|
| 306 | * | FnSig |
|---|
| 307 | * e.g.) swap (x: Object, y: Object): (Object, Object) |
|---|
| 308 | * |
|---|
| 309 | * functional declaration in components |
|---|
| 310 | * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause = Expr |
|---|
| 311 | * e.g.) swap (x, y) = (y, x) |
|---|
| 312 | * |
|---|
| 313 | * umambiguousName stores a name distinct from all other declarations |
|---|
| 314 | * (even if they have the same name in the source code). This distinct name |
|---|
| 315 | * is likely to be derived from this node's source location. |
|---|
| 316 | * |
|---|
| 317 | * implementsUnambiguousName is used to store the |
|---|
| 318 | * unambiguousName of a declaration in an exported API that is matched |
|---|
| 319 | * by this declaration. If this declaration doesn't match an exported |
|---|
| 320 | * declaration, the field is set to Option.none. |
|---|
| 321 | */ |
|---|
| 322 | FnDecl(FnHeader header, IdOrOp unambiguousName, |
|---|
| 323 | Option<Expr> body, Option<IdOrOp> implementsUnambiguousName) |
|---|
| 324 | implements Applicable, Generic; |
|---|
| 325 | /** |
|---|
| 326 | * Overloading specification |
|---|
| 327 | */ |
|---|
| 328 | _RewriteFnOverloadDecl(IdOrOp name, List<IdOrOp> fns, Option<Type> type); |
|---|
| 329 | /* the list of object expressions is a temporary hack to allow |
|---|
| 330 | progress towards earlier rewriting and caching of ASTs. -- DRC */ |
|---|
| 331 | /** |
|---|
| 332 | * Lifted object expressions |
|---|
| 333 | */ |
|---|
| 334 | _RewriteObjectExprDecl(List<_RewriteObjectExpr> objectExprs); |
|---|
| 335 | /** |
|---|
| 336 | * Injected functional methods |
|---|
| 337 | */ |
|---|
| 338 | _RewriteFunctionalMethodDecl(List<String> functionalMethodNames); |
|---|
| 339 | /** |
|---|
| 340 | * dimension and unit declaration |
|---|
| 341 | * DimUnitDecl may represent a single dimension declaration, a single |
|---|
| 342 | * unit declaration, or both dimension and unit declarations. |
|---|
| 343 | * DimUnitDecl ::= dim Id (= Type)? (unit | SI_unit) Id+ (= Expr)? |
|---|
| 344 | * | dim Id (= Type)? (default Id)? |
|---|
| 345 | * | (unit | SI_unit) Id+ (: Type)? (= Expr)? |
|---|
| 346 | */ |
|---|
| 347 | abstract DimUnitDecl(); |
|---|
| 348 | /** |
|---|
| 349 | * dimension declaration |
|---|
| 350 | * Names for dim and default must be unqualified. |
|---|
| 351 | * e.g.) dim Length SI_unit meter meters m |
|---|
| 352 | */ |
|---|
| 353 | DimDecl(Id dimId, Option<Type> derived, Option<Id> defaultId); |
|---|
| 354 | /** |
|---|
| 355 | * unit declaration |
|---|
| 356 | * Names of units must be unqualified. |
|---|
| 357 | * e.g.) unit inch inches: Length |
|---|
| 358 | */ |
|---|
| 359 | UnitDecl(boolean si_unit, List<Id> units, |
|---|
| 360 | Option<Type> dimType, Option<Expr> defExpr); |
|---|
| 361 | /** |
|---|
| 362 | * test declaration |
|---|
| 363 | * Names must be unqualified. |
|---|
| 364 | * TestDecl ::= test Id [ GeneratorClauseList ] = Expr |
|---|
| 365 | * e.g.) test fxLessThanFy[x <- E, y <- F] = assert(f(x) < f(y)) |
|---|
| 366 | */ |
|---|
| 367 | TestDecl(Id name, List<GeneratorClause> gens, Expr expr); |
|---|
| 368 | /** |
|---|
| 369 | * property declaration |
|---|
| 370 | * Names must be unqualified. |
|---|
| 371 | * PropertyDecl ::= property (Id = )? (FORALL ValParam)? Expr |
|---|
| 372 | * e.g.) property fIsMonotonic = FORALL (x:ZZ, y:ZZ) (x < y) -> (f(x) < f(y)) |
|---|
| 373 | */ |
|---|
| 374 | PropertyDecl(Option<Id> name, List<Param> params, Expr expr); |
|---|
| 375 | /** |
|---|
| 376 | * type alias declaration |
|---|
| 377 | * TypeAlias ::= type Id StaticParams? = Type |
|---|
| 378 | * e.g.) type IntList = List[\ZZ64\] |
|---|
| 379 | */ |
|---|
| 380 | TypeAlias(Id name, |
|---|
| 381 | List<StaticParam> staticParams, |
|---|
| 382 | Type typeDef); |
|---|
| 383 | /** |
|---|
| 384 | * grammar declaration |
|---|
| 385 | * Names (but not extends elements) must be unqualified. |
|---|
| 386 | */ |
|---|
| 387 | GrammarDecl(Id name, List<Id> extendsClause, |
|---|
| 388 | List<GrammarMemberDecl> members, |
|---|
| 389 | List<TransformerDecl> transformers, |
|---|
| 390 | boolean nativeDef); |
|---|
| 391 | /** |
|---|
| 392 | * grammar member (nonterminal or terminal) declaration |
|---|
| 393 | * Names and params must be unqualified. |
|---|
| 394 | */ |
|---|
| 395 | abstract GrammarMemberDecl(Id name); |
|---|
| 396 | /** |
|---|
| 397 | * nonterminal declaration |
|---|
| 398 | */ |
|---|
| 399 | abstract NonterminalDecl(List<SyntaxDecl> syntaxDecls); |
|---|
| 400 | /** |
|---|
| 401 | * nonterminal definition in nonterminal declarations |
|---|
| 402 | */ |
|---|
| 403 | NonterminalDef(NonterminalHeader header, Option<BaseType> astType); |
|---|
| 404 | /** |
|---|
| 405 | * nonterminal extending definition in nonterminal declarations |
|---|
| 406 | */ |
|---|
| 407 | NonterminalExtensionDef(); |
|---|
| 408 | /** End Decl nodes ************************************************* */ |
|---|
| 409 | |
|---|
| 410 | /** |
|---|
| 411 | * left-hand side of variable declaration or value parameter |
|---|
| 412 | */ |
|---|
| 413 | abstract Binding(Id name, Modifiers mods, |
|---|
| 414 | Option<Type> idType) implements Lhs; |
|---|
| 415 | /** |
|---|
| 416 | * left-hand side of top-level variable declaration, |
|---|
| 417 | * local variable declaration, or field declaration |
|---|
| 418 | * e.g.) var x: ZZ32 |
|---|
| 419 | * Name must be unqualified. |
|---|
| 420 | */ |
|---|
| 421 | LValue(boolean mutable); |
|---|
| 422 | /** |
|---|
| 423 | * value parameter of functional declarations and object declarations |
|---|
| 424 | * Names must be unqualified. |
|---|
| 425 | * ValParam := BindId |
|---|
| 426 | * | ( Params? ) |
|---|
| 427 | * Params ::= (Param, )* (Varargs, )? Keyword(, Keyword)* |
|---|
| 428 | * | (Param, )* Varargs |
|---|
| 429 | * | Param(, Param)* |
|---|
| 430 | * Keyword ::= Param = Expr |
|---|
| 431 | * Param ::= BindId IsType? |
|---|
| 432 | * | Type |
|---|
| 433 | * Varargs ::= BindId : Type ... |
|---|
| 434 | * e.g.) x: ZZ32 = 3 |
|---|
| 435 | * e.g.) self |
|---|
| 436 | * e.g.) x: String... |
|---|
| 437 | * |
|---|
| 438 | * <varargsType> |
|---|
| 439 | * It is a varargs parameter if the varargsType field is set. |
|---|
| 440 | */ |
|---|
| 441 | Param(Option<Expr> defaultExpr, Option<Type> varargsType); |
|---|
| 442 | |
|---|
| 443 | /** Begin Expr nodes *********************************************** */ |
|---|
| 444 | /** |
|---|
| 445 | * expression |
|---|
| 446 | */ |
|---|
| 447 | root abstract Expr(ExprInfo info); |
|---|
| 448 | /** |
|---|
| 449 | * a dummy expression that just carries a type around, used |
|---|
| 450 | * during type checking |
|---|
| 451 | */ |
|---|
| 452 | DummyExpr(); |
|---|
| 453 | /** |
|---|
| 454 | * expression annotated with a type |
|---|
| 455 | */ |
|---|
| 456 | abstract TypeAnnotatedExpr(Expr expr, Type annType); |
|---|
| 457 | /** |
|---|
| 458 | * type ascription expression |
|---|
| 459 | * Expr ::= Expr as Type |
|---|
| 460 | * e.g.) 3 as Number |
|---|
| 461 | */ |
|---|
| 462 | AsExpr(); |
|---|
| 463 | /** |
|---|
| 464 | * type assumption expression |
|---|
| 465 | * Expr ::= Expr asif Type |
|---|
| 466 | * e.g.) Empty asif List[\String\] |
|---|
| 467 | */ |
|---|
| 468 | AsIfExpr(); |
|---|
| 469 | /** |
|---|
| 470 | * assignment expression |
|---|
| 471 | * AssignExpr ::= AssignLefts AssignOp Expr |
|---|
| 472 | * AssignLefts ::= ( AssignLeft(, AssignLeft)* ) |
|---|
| 473 | * | AssignLeft |
|---|
| 474 | * AssignLeft ::= SubscriptExpr |
|---|
| 475 | * | FieldSelection |
|---|
| 476 | * | QualifiedName |
|---|
| 477 | * FieldSelection ::= Primary . Id |
|---|
| 478 | * AssignOp ::= := | Op= |
|---|
| 479 | * e.g.) x += 1 |
|---|
| 480 | * |
|---|
| 481 | * If this is a compound assignment, there should an assignment |
|---|
| 482 | * info for every constituent assignment (or 1 if there is only |
|---|
| 483 | * a single assignment). If this is not a compound assignment, |
|---|
| 484 | * then there are no assignment infos. |
|---|
| 485 | */ |
|---|
| 486 | Assignment(List<Lhs> lhs, |
|---|
| 487 | Option<FunctionalRef> assignOp, |
|---|
| 488 | Expr rhs, |
|---|
| 489 | List<CompoundAssignmentInfo> assignmentInfos); |
|---|
| 490 | /** |
|---|
| 491 | * sequence of block elements implicitly enclosed by do/end |
|---|
| 492 | * BlockElems ::= BlockElem+ |
|---|
| 493 | * DoFront ::= (at Expr)? atomic? do BlockElems? |
|---|
| 494 | * e.g.) y = x |
|---|
| 495 | * z = 2x |
|---|
| 496 | * y + z |
|---|
| 497 | * e.g.) at a.region(j) do w := a_j |
|---|
| 498 | */ |
|---|
| 499 | Block(Option<Expr> loc, boolean atomicBlock, |
|---|
| 500 | boolean withinDo, List<Expr> exprs); |
|---|
| 501 | /** |
|---|
| 502 | * do expression |
|---|
| 503 | * Do ::= (DoFront also)* DoFront end |
|---|
| 504 | * e.g.) do |
|---|
| 505 | * accum += treeSum(t.left) |
|---|
| 506 | * also do |
|---|
| 507 | * accum += treeSum(t.right) |
|---|
| 508 | * also do |
|---|
| 509 | * accum += t.datum |
|---|
| 510 | * end |
|---|
| 511 | */ |
|---|
| 512 | Do(List<Block> fronts); |
|---|
| 513 | /** |
|---|
| 514 | * case expression or extremum expression |
|---|
| 515 | * DelimitedExpr ::= case Expr Op? of CaseClauses CaseElse? end |
|---|
| 516 | * | case most Op of CaseClauses end |
|---|
| 517 | * CaseElse ::= else => BlockElems |
|---|
| 518 | * e.g.) case most > of |
|---|
| 519 | * 1 mile => "miles are larger" |
|---|
| 520 | * 1 kilometer => "we were wrong again" |
|---|
| 521 | * end |
|---|
| 522 | * eqOp and inOp are to help with disambiguation |
|---|
| 523 | */ |
|---|
| 524 | CaseExpr(Option<Expr> param, Option<FunctionalRef> compare, |
|---|
| 525 | FunctionalRef equalsOp, FunctionalRef inOp, |
|---|
| 526 | List<CaseClause> clauses, Option<Block> elseClause); |
|---|
| 527 | /** |
|---|
| 528 | * if expression |
|---|
| 529 | * DelimitedExpr ::= if CondExpr then BlockElems Elifs? Else? end |
|---|
| 530 | * | ( if CondExpr then BlockElems Elifs? Else end? ) |
|---|
| 531 | * Elif ::= elif CondExpr then BlockElems |
|---|
| 532 | * Else ::= else BlockElems |
|---|
| 533 | * CondExpr ::= BindId <- Expr |
|---|
| 534 | * | Expr |
|---|
| 535 | * e.g.) if x IN {0, 1, 2} then 0 |
|---|
| 536 | * elif x IN {3, 4, 5} then 3 |
|---|
| 537 | * else 6 end |
|---|
| 538 | */ |
|---|
| 539 | If(List<IfClause> clauses, Option<Block> elseClause); |
|---|
| 540 | /** |
|---|
| 541 | * label expression |
|---|
| 542 | * Names must be unqualified. |
|---|
| 543 | * DelimitedExpr ::= label Id BlockElems end Id |
|---|
| 544 | * e.g.) label I_95 |
|---|
| 545 | * if goingTo(Sun) |
|---|
| 546 | * then exit I_95 with x32B |
|---|
| 547 | * else x32A |
|---|
| 548 | * end |
|---|
| 549 | * end I_95 |
|---|
| 550 | */ |
|---|
| 551 | Label(Id name, Block body); |
|---|
| 552 | /** |
|---|
| 553 | * object expression |
|---|
| 554 | */ |
|---|
| 555 | abstract AbstractObjectExpr(TraitTypeHeader header); |
|---|
| 556 | /** |
|---|
| 557 | * object expression |
|---|
| 558 | * DelimitedExpr ::= object ExtendsWhere? GoInAnObject? end |
|---|
| 559 | * e.g.) object extends {List} |
|---|
| 560 | * cons(x) = Cons(x, self) |
|---|
| 561 | * append (xs) = xs |
|---|
| 562 | * end |
|---|
| 563 | */ |
|---|
| 564 | ObjectExpr(Option<SelfType> selfType); |
|---|
| 565 | /** |
|---|
| 566 | * object expression rewritten by interpreter.rewrite.Disambiguate |
|---|
| 567 | */ |
|---|
| 568 | _RewriteObjectExpr(Map<String, StaticParam> implicitTypeParameters, |
|---|
| 569 | String genSymName, |
|---|
| 570 | List<StaticArg> staticArgs, |
|---|
| 571 | Option<List<Param>> params) |
|---|
| 572 | implements ObjectConstructor; |
|---|
| 573 | /** |
|---|
| 574 | * try expression |
|---|
| 575 | * DelimitedExpr ::= try BlockElems Catch? (forbid TraitTypes)? |
|---|
| 576 | * (finally BlockElems)? end |
|---|
| 577 | * e.g.) try |
|---|
| 578 | * inp = read (file) |
|---|
| 579 | * write (inp, newFile) |
|---|
| 580 | * forbid IOException |
|---|
| 581 | * end |
|---|
| 582 | */ |
|---|
| 583 | Try(Block body, Option<Catch> catchClause, |
|---|
| 584 | List<BaseType> forbidClause, Option<Block> finallyClause); |
|---|
| 585 | /** |
|---|
| 586 | * labeled expression: tuple expression or argument expression |
|---|
| 587 | * |
|---|
| 588 | * tuple expression |
|---|
| 589 | * TupleExpr ::= ( (Expr,)+ Expr ) |
|---|
| 590 | * |
|---|
| 591 | * argument expression |
|---|
| 592 | * ArgExpr ::= ( (Expr,)* (Expr...,)? KeywordExpr(, KeywordExpr)* ) |
|---|
| 593 | * | ( (Expr,)* Expr... ) |
|---|
| 594 | * | TupleExpr |
|---|
| 595 | * e.g.) (1, 2, [3 4]..., x = 5) |
|---|
| 596 | * e.g.) (1, 2, 5) |
|---|
| 597 | */ |
|---|
| 598 | TupleExpr(List<Expr> exprs, Option<Expr> varargs, |
|---|
| 599 | List<KeywordExpr> keywords, boolean inApp); |
|---|
| 600 | /** |
|---|
| 601 | * typecase expression |
|---|
| 602 | * DelimitedExpr ::= typecase TypecaseBindings of TypecaseClauses |
|---|
| 603 | * CaseElse? end |
|---|
| 604 | * TypecaseBindings ::= TypecaseVars (= Expr)? |
|---|
| 605 | * TypecaseVars ::= BindId |
|---|
| 606 | * | ( BindId(, BindId)+ ) |
|---|
| 607 | * e.g.) typecase x = myLoser .myField of |
|---|
| 608 | * String => x.append("foo") |
|---|
| 609 | * Number => x + 3 |
|---|
| 610 | * Object => yogiBerraAutograph |
|---|
| 611 | * end |
|---|
| 612 | * Names in bind must be unqualified. |
|---|
| 613 | */ |
|---|
| 614 | Typecase(List<Id> bindIds, Option<Expr> bindExpr, |
|---|
| 615 | List<TypecaseClause> clauses, |
|---|
| 616 | Option<Block> elseClause); |
|---|
| 617 | /** |
|---|
| 618 | * while expression |
|---|
| 619 | * DelimitedExpr ::= while GeneratorClause Do |
|---|
| 620 | * e.g.) while x < 10 do print x; x += 1 end |
|---|
| 621 | */ |
|---|
| 622 | While(GeneratorClause testExpr, Do body); |
|---|
| 623 | /** |
|---|
| 624 | * for expression |
|---|
| 625 | * DelimitedExpr ::= for GeneratorClauseList DoFront end |
|---|
| 626 | * e.g.) for i <- sequential(1:5) do |
|---|
| 627 | * print (i " ") |
|---|
| 628 | * end |
|---|
| 629 | * |
|---|
| 630 | * generated expression |
|---|
| 631 | * BlockElem ::= Expr(, GeneratorClauseList)? |
|---|
| 632 | * e.g.) print (i " "), i <- sequential(1:5) |
|---|
| 633 | */ |
|---|
| 634 | For(List<GeneratorClause> gens, Block body); |
|---|
| 635 | /** |
|---|
| 636 | * comprehension or accumulator |
|---|
| 637 | */ |
|---|
| 638 | abstract BigOpApp(List<StaticArg> staticArgs); |
|---|
| 639 | /** |
|---|
| 640 | * summation and other reduction expression |
|---|
| 641 | * FlowExpr ::= Accumulator StaticArgs? |
|---|
| 642 | * ([ GeneratorClauseList ])? Expr |
|---|
| 643 | * Accumulator ::= SUM | PROD | Big Op |
|---|
| 644 | * e.g.) PROD[i <- 1:n] i |
|---|
| 645 | */ |
|---|
| 646 | Accumulator(Op accOp, List<GeneratorClause> gens, Expr body); |
|---|
| 647 | /** |
|---|
| 648 | * array comprehension |
|---|
| 649 | * Comprehension ::= BIG? [ StaticArgs? ArrayComprehensionClause+ |
|---|
| 650 | * ] |
|---|
| 651 | * e.g.) [(x, y, 1) |-> 0.0 | x <- 1:xSize, y <- 1:ySize ] |
|---|
| 652 | */ |
|---|
| 653 | ArrayComprehension(List<ArrayComprehensionClause> clauses); |
|---|
| 654 | /** |
|---|
| 655 | * atomic expression |
|---|
| 656 | * FlowExpr ::= atomic AtomicBack |
|---|
| 657 | * AtomicBack ::= AssignExpr |
|---|
| 658 | * | OpExpr |
|---|
| 659 | * | DelimitedExpr |
|---|
| 660 | * e.g.) atomic sum += a[i] |
|---|
| 661 | */ |
|---|
| 662 | AtomicExpr(Expr expr); |
|---|
| 663 | /** |
|---|
| 664 | * exiting labeled expressions |
|---|
| 665 | * FlowExpr ::= exit Id? (with Expr)? |
|---|
| 666 | * e.g.) exit I_95 with x32B |
|---|
| 667 | * Targets must be unqualified. |
|---|
| 668 | */ |
|---|
| 669 | Exit(Option<Id> target, Option<Expr> returnExpr); |
|---|
| 670 | /** |
|---|
| 671 | * spawn expression |
|---|
| 672 | * FlowExpr ::= spawn Expr |
|---|
| 673 | * e.g.) spawn mm(lefttop, right, resulttop) |
|---|
| 674 | */ |
|---|
| 675 | Spawn(Expr body); |
|---|
| 676 | /** |
|---|
| 677 | * throw expression |
|---|
| 678 | * FlowExpr ::= throw Expr |
|---|
| 679 | * e.g.) throw Error |
|---|
| 680 | */ |
|---|
| 681 | Throw(Expr expr); |
|---|
| 682 | /** |
|---|
| 683 | * tryatomic expression |
|---|
| 684 | * FlowExpr ::= tryatomic AtomicBack |
|---|
| 685 | * e.g.) tryatomic sum += a[i] |
|---|
| 686 | */ |
|---|
| 687 | TryAtomicExpr(Expr expr); |
|---|
| 688 | /** |
|---|
| 689 | * function expression |
|---|
| 690 | * Names must be unqualified. |
|---|
| 691 | * Expr ::= fn ValParam IsType? Throws? => Expr |
|---|
| 692 | * e.g.) fn x => x + 2 |
|---|
| 693 | */ |
|---|
| 694 | FnExpr(FnHeader header, Expr body) |
|---|
| 695 | implements Applicable; |
|---|
| 696 | /** |
|---|
| 697 | * expression used in block expressions |
|---|
| 698 | * BlockElem ::= LocalVarFnDecl |
|---|
| 699 | * | Expr(, GeneratorClauseList)? |
|---|
| 700 | * LocalVarFnDecl ::= LocalFnDecl+ |
|---|
| 701 | * | LocalVarDecl |
|---|
| 702 | */ |
|---|
| 703 | abstract LetExpr(Block body); |
|---|
| 704 | /** |
|---|
| 705 | * local function declaration |
|---|
| 706 | * LocalFnDecl ::= LocalFnMods? NamedFnHeaderFront FnHeaderClause |
|---|
| 707 | * = Expr |
|---|
| 708 | * e.g.) localFn(x: ZZ32) = x + 2 |
|---|
| 709 | */ |
|---|
| 710 | LetFn(List<FnDecl> fns); |
|---|
| 711 | /** |
|---|
| 712 | * local variable declaration |
|---|
| 713 | * LocalVarDecl ::= var? LocalVarWTypes InitVal |
|---|
| 714 | * | var? LocalVarWTypes |
|---|
| 715 | * | var? LocalVarWoTypes = Expr |
|---|
| 716 | * | var? LocalVarWoTypes : Type ... InitVal? |
|---|
| 717 | * | var? LocalVarWoTypes : SimpleTupleType InitVal? |
|---|
| 718 | * LocalVarWTypes ::= LocalVarWType |
|---|
| 719 | * | ( LocalVarWType(, LocalVarWType)+ ) |
|---|
| 720 | * LocalVarWType ::= BindId IsType |
|---|
| 721 | * LocalVarWoTypes ::= LocalVarWoType |
|---|
| 722 | * | ( LocalVarWoType(, LocalVarWoType)+ ) |
|---|
| 723 | * LocalVarWoType ::= BindId |
|---|
| 724 | * | Unpasting |
|---|
| 725 | * e.g.) localVar x = 3 |
|---|
| 726 | */ |
|---|
| 727 | LocalVarDecl(List<LValue> lhs, Option<Expr> rhs); |
|---|
| 728 | /** |
|---|
| 729 | * expression that is simple or using operators |
|---|
| 730 | * Expr ::= OpExpr |
|---|
| 731 | */ |
|---|
| 732 | abstract SimpleExpr(); |
|---|
| 733 | /** |
|---|
| 734 | * subscripting expression |
|---|
| 735 | * SubscriptExpr ::= Primary LeftEncloser ExprList? RightEncloser |
|---|
| 736 | * e.g.) a[i] |
|---|
| 737 | */ |
|---|
| 738 | SubscriptExpr(Expr obj, List<Expr> subs, Option<Op> op, |
|---|
| 739 | List<StaticArg> staticArgs) implements Lhs; |
|---|
| 740 | /** |
|---|
| 741 | * primary expression |
|---|
| 742 | */ |
|---|
| 743 | abstract Primary(); |
|---|
| 744 | /** |
|---|
| 745 | * literal |
|---|
| 746 | * Primary ::= LiteralExpr |
|---|
| 747 | */ |
|---|
| 748 | abstract LiteralExpr(String text); |
|---|
| 749 | /** |
|---|
| 750 | * number literal |
|---|
| 751 | */ |
|---|
| 752 | abstract NumberLiteralExpr(); |
|---|
| 753 | /** |
|---|
| 754 | * float literal |
|---|
| 755 | * e.g.) 3.5 |
|---|
| 756 | */ |
|---|
| 757 | FloatLiteralExpr(ignoreForEquals String text, |
|---|
| 758 | BigInteger intPart, |
|---|
| 759 | BigInteger numerator, int denomBase, |
|---|
| 760 | int denomPower); |
|---|
| 761 | /** |
|---|
| 762 | * int literal |
|---|
| 763 | * e.g.) 7 |
|---|
| 764 | */ |
|---|
| 765 | IntLiteralExpr(BigInteger intVal); |
|---|
| 766 | /** |
|---|
| 767 | * char literal |
|---|
| 768 | * e.g.) 'c' |
|---|
| 769 | */ |
|---|
| 770 | CharLiteralExpr(int charVal); |
|---|
| 771 | /** |
|---|
| 772 | * string literal |
|---|
| 773 | * e.g.) "string" |
|---|
| 774 | */ |
|---|
| 775 | StringLiteralExpr(); |
|---|
| 776 | /** |
|---|
| 777 | * void literal |
|---|
| 778 | * e.g.) () |
|---|
| 779 | */ |
|---|
| 780 | VoidLiteralExpr(); |
|---|
| 781 | /** |
|---|
| 782 | * variable reference |
|---|
| 783 | * VarOrFnRef ::= Id |
|---|
| 784 | * Primary ::= self |
|---|
| 785 | * e.g.) length |
|---|
| 786 | * |
|---|
| 787 | * <staticArgs> |
|---|
| 788 | * A reference to a singleton object. Created at typechecking or disambiguation-time. |
|---|
| 789 | * Necessary because object references are initially parsed as FnRefs. |
|---|
| 790 | * e.g.) Foo[\ZZ32\] |
|---|
| 791 | * where Foo was defined as |
|---|
| 792 | * object Foo[\T\] ... end |
|---|
| 793 | */ |
|---|
| 794 | VarRef(Id varId, List<StaticArg> staticArgs, |
|---|
| 795 | int lexicalDepth) implements Lhs; |
|---|
| 796 | /** |
|---|
| 797 | * field selection expression |
|---|
| 798 | * A field selection, unless it is a method reference |
|---|
| 799 | * Names of "field" must be unqualified. |
|---|
| 800 | * Primary ::= Primary . Id |
|---|
| 801 | * e.g.) Empty.length |
|---|
| 802 | */ |
|---|
| 803 | FieldRef(Expr obj, Id field) implements Lhs; |
|---|
| 804 | /** |
|---|
| 805 | * named functional in functional applications |
|---|
| 806 | */ |
|---|
| 807 | abstract FunctionalRef(List<StaticArg> staticArgs, |
|---|
| 808 | int lexicalDepth, |
|---|
| 809 | IdOrOp originalName, |
|---|
| 810 | List<IdOrOp> names, |
|---|
| 811 | List<Overloading> interpOverloadings, |
|---|
| 812 | List<Overloading> newOverloadings, |
|---|
| 813 | Option<Type> overloadingType, |
|---|
| 814 | Option<Type> overloadingSchema = Option.<Type>none()); |
|---|
| 815 | /** |
|---|
| 816 | * expression with static instantiations |
|---|
| 817 | * list of ids allows cross-API overloading |
|---|
| 818 | * Primary ::= Id[\StaticArgList\] |
|---|
| 819 | * e.g.) identity[\String\] |
|---|
| 820 | * |
|---|
| 821 | * <overloadings> |
|---|
| 822 | * A list of FnRefs used for infering static arguments. Used only between the two |
|---|
| 823 | * passes of the typechecker. Indicates that one of these FnRefs, which each have |
|---|
| 824 | * different instantiations of static arguments, should be the correct instantiation. |
|---|
| 825 | * |
|---|
| 826 | * <overloadingType> |
|---|
| 827 | * type of a particular overloading |
|---|
| 828 | */ |
|---|
| 829 | FnRef(); |
|---|
| 830 | /** |
|---|
| 831 | * operator name with (inferred) static instantiations |
|---|
| 832 | * list of operators allows cross-API overloading |
|---|
| 833 | * Primary ::= Op[\StaticArgList\] |
|---|
| 834 | * e.g.) +[\String\] |
|---|
| 835 | * |
|---|
| 836 | * <overloadings> |
|---|
| 837 | * Similar to FnRef, this node is used for inferring static |
|---|
| 838 | * arguments to an Op call. This node only exists between the first and second |
|---|
| 839 | * passes of the typechecker. Holds several different instantiations of static args, |
|---|
| 840 | * one of which may be the correct insantiation. |
|---|
| 841 | * |
|---|
| 842 | * <overloadingType> |
|---|
| 843 | * type of a particular overloading |
|---|
| 844 | */ |
|---|
| 845 | OpRef(); |
|---|
| 846 | /** |
|---|
| 847 | * The rewriting to explicitly name self and parent |
|---|
| 848 | * pre-interpretation may generalize the dotted |
|---|
| 849 | * list from a FnRef into something else. |
|---|
| 850 | */ |
|---|
| 851 | _RewriteFnRef(Expr fnExpr, List<StaticArg> staticArgs); |
|---|
| 852 | /** |
|---|
| 853 | * Temporarily, until closure conversion is always on-line, |
|---|
| 854 | * object exprs are simply hoisted to top-level, but retain |
|---|
| 855 | * access to their original lexical scope. |
|---|
| 856 | */ |
|---|
| 857 | _RewriteObjectExprRef(String genSymName, List<StaticArg> staticArgs); |
|---|
| 858 | /** |
|---|
| 859 | * juxtaposition of expressions |
|---|
| 860 | * If this node turns out to actually be a juxtaposition, |
|---|
| 861 | * based on the types, the op field is a reference to |
|---|
| 862 | * the operator that should be used. |
|---|
| 863 | * |
|---|
| 864 | * In order to know whether a juxtaposition is an infix or |
|---|
| 865 | * multifix juxtaposition, we need type information. |
|---|
| 866 | * |
|---|
| 867 | * After type checking, this node should disappear. |
|---|
| 868 | * |
|---|
| 869 | * Primary ::= Primary . Id StaticArgs? ParenthesisDelimited |
|---|
| 870 | * | Primary TupleExpr |
|---|
| 871 | * | Primary Primary |
|---|
| 872 | * e.g.) myString.replace("foo", "few") |
|---|
| 873 | * e.g.) log log n |
|---|
| 874 | * |
|---|
| 875 | * loose juxtaposition |
|---|
| 876 | * juxtaposition with intervening whitespace |
|---|
| 877 | * e.g.) 3 5 |
|---|
| 878 | * |
|---|
| 879 | * tight juxtaposition |
|---|
| 880 | * juxtaposition without intervening whitespace. If fnApp is true, |
|---|
| 881 | * then this juxtaposition should be type checked ONLY as a function |
|---|
| 882 | * application. This should be the case for desugarings only. |
|---|
| 883 | * e.g.) f(3+5) |
|---|
| 884 | */ |
|---|
| 885 | Juxt(FunctionalRef multiJuxt, FunctionalRef infixJuxt, |
|---|
| 886 | List<Expr> exprs, boolean fnApp, boolean tight) |
|---|
| 887 | implements OutAfterTypeChecking; |
|---|
| 888 | /** |
|---|
| 889 | * functional application |
|---|
| 890 | * Primary ::= Primary ArgExpr |
|---|
| 891 | * | Primary Primary |
|---|
| 892 | * e.g.) x y |
|---|
| 893 | */ |
|---|
| 894 | _RewriteFnApp(Expr function, Expr argument) |
|---|
| 895 | implements InAfterTypeChecking; |
|---|
| 896 | /** |
|---|
| 897 | * expression using operators |
|---|
| 898 | * (list of ops allows cross-API overloading) |
|---|
| 899 | * OpExpr ::= EncloserOp OpExpr? EncloserOp? |
|---|
| 900 | * | OpExpr EncloserOp OpExpr? |
|---|
| 901 | * | Primary |
|---|
| 902 | * EncloserOp ::= Encloser |
|---|
| 903 | * | Op |
|---|
| 904 | * Primary ::= LeftEncloser ExprList? RightEncloser |
|---|
| 905 | * | Primary ^ Exponent |
|---|
| 906 | * | Primary ExponentOp |
|---|
| 907 | * e.g.) 3 + 5 |
|---|
| 908 | */ |
|---|
| 909 | OpExpr(FunctionalRef op, List<Expr> args); |
|---|
| 910 | /** |
|---|
| 911 | * If an expression uses and operator, and that operator |
|---|
| 912 | * looks at parse-time like a multifix operator, it |
|---|
| 913 | * an AmbigMultifixOpExpr node is created, because it is |
|---|
| 914 | * unclear until typechecking and overloading resolution |
|---|
| 915 | * whether it should be one multifix application or several |
|---|
| 916 | * infix applications. |
|---|
| 917 | * |
|---|
| 918 | * e.g.) 3+4+5+6 |
|---|
| 919 | */ |
|---|
| 920 | AmbiguousMultifixOpExpr(FunctionalRef infix_op, |
|---|
| 921 | FunctionalRef multifix_op, |
|---|
| 922 | List<Expr> args) |
|---|
| 923 | implements OutAfterTypeChecking; |
|---|
| 924 | /** |
|---|
| 925 | * chain expression |
|---|
| 926 | * Certain infix mathematical operators that are |
|---|
| 927 | * traditionally regarded as relational operators, |
|---|
| 928 | * delivering boolean results, may be chained. |
|---|
| 929 | * e.g.) A SUBSETEQ B SUBSET C SUBSETEQ D |
|---|
| 930 | */ |
|---|
| 931 | ChainExpr(Expr first, |
|---|
| 932 | List<Link> links, |
|---|
| 933 | FunctionalRef andOp); |
|---|
| 934 | /** |
|---|
| 935 | * coercion invocation |
|---|
| 936 | * internal node created by static analysis |
|---|
| 937 | * after inferring the implicit coercion invocations |
|---|
| 938 | */ |
|---|
| 939 | abstract CoercionInvocation(Type toType, |
|---|
| 940 | Expr arg); |
|---|
| 941 | /** |
|---|
| 942 | * Coercion invocation to a trait type. The FnRef is |
|---|
| 943 | * the actual function that coercion calls, along |
|---|
| 944 | * with any static args for the coercion. |
|---|
| 945 | */ |
|---|
| 946 | TraitCoercionInvocation( |
|---|
| 947 | TraitType toType, |
|---|
| 948 | FnRef coercionFn); |
|---|
| 949 | /** |
|---|
| 950 | * Coercion invocation to a tuple type. Each type |
|---|
| 951 | * in the tuple may or may not require a coercion; |
|---|
| 952 | * the list of options corresponds to those that do. |
|---|
| 953 | */ |
|---|
| 954 | TupleCoercionInvocation( |
|---|
| 955 | TupleType toType, |
|---|
| 956 | List<Option<CoercionInvocation>> subCoercions, |
|---|
| 957 | Option<Option<CoercionInvocation>> varargCoercion); |
|---|
| 958 | /** |
|---|
| 959 | * Coercion invocation to an arrow type. Each type |
|---|
| 960 | * in the arrow may or may not require a coercion; |
|---|
| 961 | * the two options correspond to those that do. |
|---|
| 962 | */ |
|---|
| 963 | ArrowCoercionInvocation( |
|---|
| 964 | ArrowType toType, |
|---|
| 965 | Option<CoercionInvocation> domainCoercion, |
|---|
| 966 | Option<CoercionInvocation> rangeCoercion); |
|---|
| 967 | /** |
|---|
| 968 | * Coercion invocation from a union type. Some non- |
|---|
| 969 | * empty subset of the constituent types must each |
|---|
| 970 | * coerce to the desired type. |
|---|
| 971 | */ |
|---|
| 972 | UnionCoercionInvocation( |
|---|
| 973 | List<Type> fromTypes, |
|---|
| 974 | List<Option<CoercionInvocation>> fromCoercions); |
|---|
| 975 | /** |
|---|
| 976 | * a method invocation |
|---|
| 977 | * some are created by parsing, while others require later |
|---|
| 978 | * static analysis to disambiguate from function applications |
|---|
| 979 | * |
|---|
| 980 | * Names of "method" must be unqualified. |
|---|
| 981 | * e.g.) myString.toUppercase() |
|---|
| 982 | */ |
|---|
| 983 | MethodInvocation(Expr obj, Id method, |
|---|
| 984 | List<StaticArg> staticArgs, |
|---|
| 985 | Expr arg, |
|---|
| 986 | Option<Type> overloadingType = Option.<Type>none(), |
|---|
| 987 | Option<Type> overloadingSchema = Option.<Type>none()); |
|---|
| 988 | /** |
|---|
| 989 | * primary expression without any dots |
|---|
| 990 | * MathPrimary ::= PrimaryFront MathItem* |
|---|
| 991 | * e.g.) a[3, 4] |
|---|
| 992 | */ |
|---|
| 993 | MathPrimary(FunctionalRef multiJuxt, |
|---|
| 994 | FunctionalRef infixJuxt, |
|---|
| 995 | Expr front, List<MathItem> rest) |
|---|
| 996 | implements OutAfterTypeChecking; |
|---|
| 997 | /** |
|---|
| 998 | * array expression |
|---|
| 999 | * ArrayExpr ::= [ StaticArgs? RectElements ] |
|---|
| 1000 | * RectElements ::= Expr MultiDimCons* |
|---|
| 1001 | * MultiDimCons ::= RectSeparator Expr |
|---|
| 1002 | * RectSeparator ::= ;+ |
|---|
| 1003 | * | Whitespace |
|---|
| 1004 | * e.g.) [1 2 3; 4 5 6; 7 8 9] |
|---|
| 1005 | */ |
|---|
| 1006 | abstract ArrayExpr(List<StaticArg> staticArgs); |
|---|
| 1007 | /** |
|---|
| 1008 | * array with a single element |
|---|
| 1009 | * e.g.) [3] |
|---|
| 1010 | */ |
|---|
| 1011 | ArrayElement(Expr element); |
|---|
| 1012 | /** |
|---|
| 1013 | * array with multiple elements |
|---|
| 1014 | * e.g.) [3 4 5; 6 7 8] |
|---|
| 1015 | */ |
|---|
| 1016 | ArrayElements(int dimension, List<ArrayExpr> elements, |
|---|
| 1017 | boolean outermost); |
|---|
| 1018 | /** End Expr nodes ************************************************* */ |
|---|
| 1019 | |
|---|
| 1020 | /** Begin Type nodes *********************************************** */ |
|---|
| 1021 | /** |
|---|
| 1022 | * type |
|---|
| 1023 | */ |
|---|
| 1024 | root abstract Type(TypeInfo info); |
|---|
| 1025 | /** |
|---|
| 1026 | * base types: things that can be extended, excluded, thrown, etc. |
|---|
| 1027 | */ |
|---|
| 1028 | abstract BaseType(); |
|---|
| 1029 | /** |
|---|
| 1030 | * any type |
|---|
| 1031 | * e.g.) Any |
|---|
| 1032 | */ |
|---|
| 1033 | AnyType(); |
|---|
| 1034 | /** |
|---|
| 1035 | * bottom type |
|---|
| 1036 | * internal node |
|---|
| 1037 | */ |
|---|
| 1038 | BottomType(); |
|---|
| 1039 | /** |
|---|
| 1040 | * the type of a FnExpr domain that could not be inferred |
|---|
| 1041 | * internal node |
|---|
| 1042 | */ |
|---|
| 1043 | UnknownType(); |
|---|
| 1044 | /** |
|---|
| 1045 | * the type of "self" in a trait or object |
|---|
| 1046 | * internal node |
|---|
| 1047 | */ |
|---|
| 1048 | abstract SelfType(); |
|---|
| 1049 | /** |
|---|
| 1050 | * the type of "self" in a trait or object declaration |
|---|
| 1051 | * internal node |
|---|
| 1052 | */ |
|---|
| 1053 | TraitSelfType(BaseType named, List<NamedType> comprised); |
|---|
| 1054 | /** |
|---|
| 1055 | * the type of "self" in an object expression |
|---|
| 1056 | * internal node |
|---|
| 1057 | */ |
|---|
| 1058 | ObjectExprType(List<BaseType> extended); |
|---|
| 1059 | /** |
|---|
| 1060 | * named type |
|---|
| 1061 | */ |
|---|
| 1062 | abstract NamedType(Id name); |
|---|
| 1063 | /** |
|---|
| 1064 | * a type variable |
|---|
| 1065 | * TraitType ::= QualifiedName |
|---|
| 1066 | * e.g.) T |
|---|
| 1067 | */ |
|---|
| 1068 | VarType(int lexicalDepth); |
|---|
| 1069 | /** |
|---|
| 1070 | * a trait (object, alias, or proper trait) type; traits |
|---|
| 1071 | * without params are referenced with an empty arg list |
|---|
| 1072 | * TraitType ::= QualifiedName [\StaticArgList\] |
|---|
| 1073 | * e.g.) List[\ZZ32\] |
|---|
| 1074 | * |
|---|
| 1075 | * <staticParams> |
|---|
| 1076 | * If the staticParams field is set, |
|---|
| 1077 | * it is the type of a generic singleton |
|---|
| 1078 | * used during static checking |
|---|
| 1079 | */ |
|---|
| 1080 | TraitType(List<StaticArg> args, |
|---|
| 1081 | List<StaticParam> staticParams); |
|---|
| 1082 | /** |
|---|
| 1083 | * abbreviated type |
|---|
| 1084 | */ |
|---|
| 1085 | abstract AbbreviatedType(Type elemType); |
|---|
| 1086 | /** |
|---|
| 1087 | * array type |
|---|
| 1088 | * TraitType ::= Type [ ArraySize? ] |
|---|
| 1089 | * e.g.) ZZ64[3, 2] |
|---|
| 1090 | */ |
|---|
| 1091 | ArrayType(Indices indices) implements OutAfterTypeChecking; |
|---|
| 1092 | /** |
|---|
| 1093 | * matrix type |
|---|
| 1094 | * TraitType ::= Type ^ IntExpr |
|---|
| 1095 | * | Type ^ ( ExtentRange (BY ExtentRange)* ) |
|---|
| 1096 | * e.g.) ZZ32^3 |
|---|
| 1097 | */ |
|---|
| 1098 | MatrixType(List<ExtentRange> dimensions) |
|---|
| 1099 | implements OutAfterTypeChecking; |
|---|
| 1100 | /** |
|---|
| 1101 | * type with dimension |
|---|
| 1102 | * DimType ::= Type DimExpr (in Expr)? |
|---|
| 1103 | * e.g.) RR64 Length |
|---|
| 1104 | */ |
|---|
| 1105 | TaggedDimType(DimExpr dimExpr, Option<Expr> unitExpr); |
|---|
| 1106 | /** |
|---|
| 1107 | * type with unit |
|---|
| 1108 | * DimType ::= Type Expr |
|---|
| 1109 | * e.g.) RR64 meter |
|---|
| 1110 | */ |
|---|
| 1111 | TaggedUnitType(Expr unitExpr); |
|---|
| 1112 | /** |
|---|
| 1113 | * tuple-like types |
|---|
| 1114 | * TupleType ::= ( Type, TypeList ) |
|---|
| 1115 | * e.g.) (ZZ32, String) |
|---|
| 1116 | * |
|---|
| 1117 | * domain of an arrow type |
|---|
| 1118 | * ArgType ::= |
|---|
| 1119 | * ( (Type, )* (Type ... , )? KeywordType(, KeywordType)* ) |
|---|
| 1120 | * | ( (Type, )* Type ... ) |
|---|
| 1121 | * | TupleType |
|---|
| 1122 | * e.g.) ZZ32 |
|---|
| 1123 | * e.g.) (String, ZZ32, String..., foo=ZZ32) |
|---|
| 1124 | * |
|---|
| 1125 | * If this tuple type does not have any elements, |
|---|
| 1126 | * it is a void type. |
|---|
| 1127 | * void type |
|---|
| 1128 | * NonArrowType ::= () |
|---|
| 1129 | * e.g.) () |
|---|
| 1130 | * |
|---|
| 1131 | * <varargs> |
|---|
| 1132 | * It has a varargs parameter if the varargs field is set. |
|---|
| 1133 | */ |
|---|
| 1134 | TupleType(List<Type> elements, Option<Type> varargs, |
|---|
| 1135 | List<KeywordType> keywords); |
|---|
| 1136 | /** |
|---|
| 1137 | * arrow type |
|---|
| 1138 | * Type ::= io? Type -> Type Throws? |
|---|
| 1139 | * e.g.) (String, NN..., p = Printer) -> NN throws IOException |
|---|
| 1140 | * |
|---|
| 1141 | * <staticParams> |
|---|
| 1142 | * <whereClause> |
|---|
| 1143 | * type of a generic function, used during static checking |
|---|
| 1144 | */ |
|---|
| 1145 | ArrowType(Type domain, |
|---|
| 1146 | Type range, |
|---|
| 1147 | Effect effect, |
|---|
| 1148 | boolean io, |
|---|
| 1149 | Option<MethodInfo> methodInfo = Option.<MethodInfo>none()); |
|---|
| 1150 | /** |
|---|
| 1151 | * inferred type |
|---|
| 1152 | * Used internally for type analysis |
|---|
| 1153 | */ |
|---|
| 1154 | _InferenceVarType(Object id) implements OutAfterTypeChecking; |
|---|
| 1155 | /** |
|---|
| 1156 | * An intersection or union. |
|---|
| 1157 | */ |
|---|
| 1158 | abstract BoundType(List<Type> elements); |
|---|
| 1159 | /** |
|---|
| 1160 | * An intersection. Used internally for type analysis. |
|---|
| 1161 | */ |
|---|
| 1162 | IntersectionType(); |
|---|
| 1163 | /** |
|---|
| 1164 | * A union. Used internally for type analysis. |
|---|
| 1165 | */ |
|---|
| 1166 | UnionType(); |
|---|
| 1167 | /** |
|---|
| 1168 | * Fixed point (a.k.a. "mu") type. Used internally for type analysis. |
|---|
| 1169 | */ |
|---|
| 1170 | FixedPointType(_InferenceVarType name, Type body); |
|---|
| 1171 | /** |
|---|
| 1172 | * The type of the name given to a label expression. Used internally. |
|---|
| 1173 | */ |
|---|
| 1174 | LabelType(); |
|---|
| 1175 | /** |
|---|
| 1176 | * dimension expression (not really a type, but here for |
|---|
| 1177 | * now because of the way the parser is defined) |
|---|
| 1178 | */ |
|---|
| 1179 | abstract DimExpr(); |
|---|
| 1180 | /* base dimension |
|---|
| 1181 | * DimExpr ::= Unity |
|---|
| 1182 | * e.g.) Unity |
|---|
| 1183 | */ |
|---|
| 1184 | DimBase(); |
|---|
| 1185 | /* dimension identifier |
|---|
| 1186 | * DimExpr ::= QualifiedName |
|---|
| 1187 | * e.g.) com.sun.fortress.dim.Length |
|---|
| 1188 | */ |
|---|
| 1189 | DimRef(Id name); |
|---|
| 1190 | /* vector type or exponent dimemsion |
|---|
| 1191 | * resolved during parsing |
|---|
| 1192 | * after parsing the base field should be of type DimExpr |
|---|
| 1193 | * e.g.) ZZ32^3 |
|---|
| 1194 | * |
|---|
| 1195 | * dimension exponentiation |
|---|
| 1196 | * DimExpr ::= DimExpr ^ IntExpr |
|---|
| 1197 | * e.g.) Time^2 |
|---|
| 1198 | */ |
|---|
| 1199 | DimExponent(Type base, IntExpr power); |
|---|
| 1200 | /* dimension with an unary operator |
|---|
| 1201 | * DimExpr ::= DimPrefixOp DimExpr |
|---|
| 1202 | * | DimExpr DimPostfixOp |
|---|
| 1203 | * e.g.) Time squared |
|---|
| 1204 | */ |
|---|
| 1205 | DimUnaryOp(DimExpr dimVal, Op op); |
|---|
| 1206 | /* dimension with a binary operator |
|---|
| 1207 | * |
|---|
| 1208 | * dimension multiplication |
|---|
| 1209 | * DimExpr ::= DimExpr DOT DimExpr |
|---|
| 1210 | * | DimExpr DimExpr |
|---|
| 1211 | * e.g.) Length Mass |
|---|
| 1212 | * |
|---|
| 1213 | * dimension division |
|---|
| 1214 | * DimExpr ::= DimExpr / DimExpr |
|---|
| 1215 | * | DimExpr per DimExpr |
|---|
| 1216 | * | 1 / DimExpr |
|---|
| 1217 | * e.g.) Length / Time |
|---|
| 1218 | */ |
|---|
| 1219 | DimBinaryOp(DimExpr left, DimExpr right, Op op); |
|---|
| 1220 | /** End Type nodes ************************************************* */ |
|---|
| 1221 | |
|---|
| 1222 | /** Begin StaticArg nodes ****************************************** */ |
|---|
| 1223 | /** |
|---|
| 1224 | * static argument |
|---|
| 1225 | */ |
|---|
| 1226 | root abstract StaticArg(ignoreForEquals boolean lifted = false); |
|---|
| 1227 | /** |
|---|
| 1228 | * type used as static argument |
|---|
| 1229 | * StaticArg ::= Type |
|---|
| 1230 | * e.g.) List[\ZZ64\] |
|---|
| 1231 | */ |
|---|
| 1232 | TypeArg(Type typeArg); |
|---|
| 1233 | /** |
|---|
| 1234 | * integer used as static argument |
|---|
| 1235 | * StaticArg ::= IntExpr |
|---|
| 1236 | * e.g.) m + n |
|---|
| 1237 | */ |
|---|
| 1238 | IntArg(IntExpr intVal); |
|---|
| 1239 | /** |
|---|
| 1240 | * boolean used as static argument |
|---|
| 1241 | * StaticArg ::= BoolExpr |
|---|
| 1242 | * e.g.) ninf OR pinf |
|---|
| 1243 | */ |
|---|
| 1244 | BoolArg(BoolExpr boolArg); |
|---|
| 1245 | /** |
|---|
| 1246 | * operator used as static argument |
|---|
| 1247 | * StaticArg ::= Op |
|---|
| 1248 | * e.g.) + |
|---|
| 1249 | */ |
|---|
| 1250 | OpArg(FunctionalRef name); |
|---|
| 1251 | /** |
|---|
| 1252 | * dimension used as static argument |
|---|
| 1253 | * StaticArg ::= Type |
|---|
| 1254 | * e.g.) Unity |
|---|
| 1255 | */ |
|---|
| 1256 | DimArg(DimExpr dimArg); |
|---|
| 1257 | /** |
|---|
| 1258 | * unit used as static argument |
|---|
| 1259 | * StaticArg ::= UnitExpr |
|---|
| 1260 | * e.g.) dimensionless |
|---|
| 1261 | */ |
|---|
| 1262 | UnitArg(UnitExpr unitArg); |
|---|
| 1263 | /** End StaticArg nodes ******************************************** */ |
|---|
| 1264 | |
|---|
| 1265 | /** Begin StaticExpr nodes ***************************************** */ |
|---|
| 1266 | /** |
|---|
| 1267 | * static expression |
|---|
| 1268 | */ |
|---|
| 1269 | abstract StaticExpr(ignoreForEquals boolean parenthesized); |
|---|
| 1270 | /** |
|---|
| 1271 | * integer expression |
|---|
| 1272 | * StaticExpr ::= IntExpr |
|---|
| 1273 | * IntExpr ::= IntVal |
|---|
| 1274 | */ |
|---|
| 1275 | abstract IntExpr(); |
|---|
| 1276 | /** |
|---|
| 1277 | * integer number |
|---|
| 1278 | * IntVal ::= IntLiteralExpr |
|---|
| 1279 | * e.g.) 8 |
|---|
| 1280 | */ |
|---|
| 1281 | IntBase(IntLiteralExpr intVal); |
|---|
| 1282 | /** |
|---|
| 1283 | * integer identifier |
|---|
| 1284 | * IntVal ::= QualifiedName |
|---|
| 1285 | * e.g.) m |
|---|
| 1286 | */ |
|---|
| 1287 | IntRef(Id name, int lexicalDepth); |
|---|
| 1288 | /** |
|---|
| 1289 | * integer expression with an operator |
|---|
| 1290 | * |
|---|
| 1291 | * integer addition |
|---|
| 1292 | * IntExpr ::= IntExpr + IntExpr |
|---|
| 1293 | * e.g.) m + 2 |
|---|
| 1294 | * |
|---|
| 1295 | * integer subtraction |
|---|
| 1296 | * IntExpr ::= IntExpr - IntExpr |
|---|
| 1297 | * e.g.) m - 2 |
|---|
| 1298 | * |
|---|
| 1299 | * integer multiplication |
|---|
| 1300 | * IntExpr ::= IntExpr IntExpr |
|---|
| 1301 | * | IntExpr DOT IntExpr |
|---|
| 1302 | * e.g.) m DOT n |
|---|
| 1303 | * |
|---|
| 1304 | * integer exponentiation |
|---|
| 1305 | * IntExpr ::= IntExpr caret IntVal |
|---|
| 1306 | * e.g.) 2^b |
|---|
| 1307 | */ |
|---|
| 1308 | IntBinaryOp(IntExpr left, IntExpr right, Op op); |
|---|
| 1309 | /** |
|---|
| 1310 | * boolean expression |
|---|
| 1311 | * StaticExpr ::= BoolExpr |
|---|
| 1312 | * BoolExpr ::= BoolVal |
|---|
| 1313 | */ |
|---|
| 1314 | abstract BoolExpr(); |
|---|
| 1315 | /** |
|---|
| 1316 | * boolean constant |
|---|
| 1317 | * BoolVal ::= true | false |
|---|
| 1318 | * e.g.) true |
|---|
| 1319 | */ |
|---|
| 1320 | BoolBase(boolean boolVal); |
|---|
| 1321 | /** |
|---|
| 1322 | * boolean identiier |
|---|
| 1323 | * BoolVal ::= QualifiedName |
|---|
| 1324 | * e.g.) ninf |
|---|
| 1325 | */ |
|---|
| 1326 | BoolRef(Id name, int lexicalDepth); |
|---|
| 1327 | /** |
|---|
| 1328 | * boolean constraint |
|---|
| 1329 | * BoolExpr ::= BoolConstraint |
|---|
| 1330 | */ |
|---|
| 1331 | abstract BoolConstraint(); |
|---|
| 1332 | /** |
|---|
| 1333 | * unary boolean constraint |
|---|
| 1334 | * BoolConstraint ::= NOT BoolExpr |
|---|
| 1335 | * e.g.) NOT ninf |
|---|
| 1336 | */ |
|---|
| 1337 | BoolUnaryOp(BoolExpr boolVal, Op op); |
|---|
| 1338 | /** |
|---|
| 1339 | * binary boolean constraint |
|---|
| 1340 | * BoolConstraint ::= BoolExpr OR BoolExpr |
|---|
| 1341 | * | BoolExpr AND BoolExpr |
|---|
| 1342 | * | BoolExpr IMPLIES BoolExpr |
|---|
| 1343 | * | BoolExpr = BoolExpr |
|---|
| 1344 | * e.g.) ninf OR pinf |
|---|
| 1345 | */ |
|---|
| 1346 | BoolBinaryOp(BoolExpr left, BoolExpr right, Op op); |
|---|
| 1347 | /** |
|---|
| 1348 | * unit expression |
|---|
| 1349 | * StaticExpr ::= UnitExpr |
|---|
| 1350 | */ |
|---|
| 1351 | abstract UnitExpr(); |
|---|
| 1352 | /** |
|---|
| 1353 | * unit identifier |
|---|
| 1354 | * UnitExpr ::= dimensionless |
|---|
| 1355 | * | QualifiedName |
|---|
| 1356 | * e.g.) m |
|---|
| 1357 | */ |
|---|
| 1358 | UnitRef(Id name); |
|---|
| 1359 | /** |
|---|
| 1360 | * unit expression with an operator |
|---|
| 1361 | * UnitExpr ::= UnitExpr UnitExpr |
|---|
| 1362 | * | UnitExpr DOT UnitExpr |
|---|
| 1363 | * | UnitExpr / UnitExpr |
|---|
| 1364 | * | UnitExpr per UnitExpr |
|---|
| 1365 | * | UnitExpr caret UnitExpr |
|---|
| 1366 | * e.g.) m DOT n |
|---|
| 1367 | * e.g.) meter / second |
|---|
| 1368 | * e.g.) meter^2 |
|---|
| 1369 | */ |
|---|
| 1370 | UnitBinaryOp(UnitExpr left, UnitExpr right, Op op); |
|---|
| 1371 | /** End StaticExpr nodes ******************************************* */ |
|---|
| 1372 | |
|---|
| 1373 | /** |
|---|
| 1374 | * effect on arrow types |
|---|
| 1375 | * e.g.) throws FailCalled |
|---|
| 1376 | */ |
|---|
| 1377 | Effect(Option<List<Type>> throwsClause, boolean ioEffect); |
|---|
| 1378 | /** |
|---|
| 1379 | * where clause used in trait, object, and functional declarations |
|---|
| 1380 | * Where ::= where [\ WhereBindingList \] ({ WhereConstraintList })? |
|---|
| 1381 | * | where { WhereConstraintList } |
|---|
| 1382 | * e.g.) where { ninf AND NOT nan } |
|---|
| 1383 | */ |
|---|
| 1384 | WhereClause(List<WhereBinding> bindings, |
|---|
| 1385 | List<WhereConstraint> constraints); |
|---|
| 1386 | /** |
|---|
| 1387 | * hidden type variable binding declared in where clauses |
|---|
| 1388 | * Names must be unqualified. |
|---|
| 1389 | * |
|---|
| 1390 | * WhereBinding ::= Id Extends? |
|---|
| 1391 | * | nat Id |
|---|
| 1392 | * | int Id |
|---|
| 1393 | * | bool Id |
|---|
| 1394 | * | unit Id |
|---|
| 1395 | * Extends ::= extends TraitTypes |
|---|
| 1396 | * e.g.) T extends Object |
|---|
| 1397 | * e.g.) nat length |
|---|
| 1398 | * e.g.) int length |
|---|
| 1399 | * e.g.) bool ninf |
|---|
| 1400 | * e.g.) unit U |
|---|
| 1401 | */ |
|---|
| 1402 | WhereBinding(Id name, List<BaseType> supers, StaticParamKind kind); |
|---|
| 1403 | /** |
|---|
| 1404 | * hidden type variable constraint declared in where clauses |
|---|
| 1405 | */ |
|---|
| 1406 | abstract WhereConstraint(); |
|---|
| 1407 | /** |
|---|
| 1408 | * type variable constraint declared in where clauses |
|---|
| 1409 | * WhereConstraint ::= Id Extends |
|---|
| 1410 | * e.g.) T extends Object |
|---|
| 1411 | */ |
|---|
| 1412 | WhereExtends(Id name, List<BaseType> supers); |
|---|
| 1413 | /** |
|---|
| 1414 | * type alias declaration |
|---|
| 1415 | * TypeAlias ::= type Id StaticParams? = Type |
|---|
| 1416 | * e.g.) type IntList = List[\ZZ64\] |
|---|
| 1417 | */ |
|---|
| 1418 | WhereTypeAlias(TypeAlias alias); |
|---|
| 1419 | /** |
|---|
| 1420 | * coercion constraint declared in where clauses |
|---|
| 1421 | * WhereConstraint ::= Type coerces Type |
|---|
| 1422 | * | Type widens Type |
|---|
| 1423 | * CoercionWhereConstraint ::= Type widens or coerces Type |
|---|
| 1424 | * e.g.) T coerces Identity[\ODOT\] |
|---|
| 1425 | * e.g.) T widens S |
|---|
| 1426 | * e.g.) T widens or coerces S |
|---|
| 1427 | */ |
|---|
| 1428 | WhereCoerces(Type left, Type right, boolean coerces, boolean widens); |
|---|
| 1429 | /** |
|---|
| 1430 | * DottedId equality constraint declared in where clauses |
|---|
| 1431 | * WhereConstraint ::= QualifiedName = QualifiedName |
|---|
| 1432 | * e.g.) m = n |
|---|
| 1433 | */ |
|---|
| 1434 | WhereEquals(Id left, Id right); |
|---|
| 1435 | /** |
|---|
| 1436 | * unit constraint used in where clauses |
|---|
| 1437 | * WhereConstraint ::= dimensionless = Id |
|---|
| 1438 | * | Id = dimensionless |
|---|
| 1439 | * e.g.) U = dimensionless |
|---|
| 1440 | */ |
|---|
| 1441 | UnitConstraint(Id name); |
|---|
| 1442 | /** |
|---|
| 1443 | * integer constraint used in where clauses |
|---|
| 1444 | * WhereConstraint ::= IntConstraint |
|---|
| 1445 | * IntConstraint ::= IntExpr <= IntExpr |
|---|
| 1446 | * | IntExpr < IntExpr |
|---|
| 1447 | * | IntExpr >= IntExpr |
|---|
| 1448 | * | IntExpr > IntExpr |
|---|
| 1449 | * | IntExpr = IntExpr |
|---|
| 1450 | * e.g.) b <= c |
|---|
| 1451 | * e.g.) 0 < a |
|---|
| 1452 | * e.g.) b >= c |
|---|
| 1453 | * e.g.) a > 0 |
|---|
| 1454 | * e.g.) 8 = 2^3 |
|---|
| 1455 | */ |
|---|
| 1456 | IntConstraint(IntExpr left, IntExpr right, Op op); |
|---|
| 1457 | /** |
|---|
| 1458 | * boolean constraint declared in where clauses |
|---|
| 1459 | * WhereConstraint ::= BoolConstraint |
|---|
| 1460 | * e.g.) pinf AND ninf |
|---|
| 1461 | */ |
|---|
| 1462 | BoolConstraintExpr(BoolConstraint constraint); |
|---|
| 1463 | /** |
|---|
| 1464 | * contracts used in functional declarations and object declarations |
|---|
| 1465 | * Contract ::= Requires? Ensures? Invariant? |
|---|
| 1466 | * Requires ::= requires { ExprList? } |
|---|
| 1467 | * Ensures ::= ensures { EnsuresClauseList? } |
|---|
| 1468 | * Invariant ::= invariant { ExprList? } |
|---|
| 1469 | * CoercionContract ::= Ensures? Invariant? |
|---|
| 1470 | * e.g.) requires { n GE 0 } ensures { outcome GE 0 } |
|---|
| 1471 | */ |
|---|
| 1472 | Contract(Option<List<Expr>> requiresClause, |
|---|
| 1473 | Option<List<EnsuresClause>> ensuresClause, |
|---|
| 1474 | Option<List<Expr>> invariantsClause); |
|---|
| 1475 | /** |
|---|
| 1476 | * ensures clause used in contracts |
|---|
| 1477 | * EnsuresClause ::= Expr (provided Expr)? |
|---|
| 1478 | * e.g.) sorted(outcome) provided sorted(input) |
|---|
| 1479 | */ |
|---|
| 1480 | EnsuresClause(Expr post, Option<Expr> pre); |
|---|
| 1481 | /** |
|---|
| 1482 | * static parameter |
|---|
| 1483 | * Names must be unqualified. |
|---|
| 1484 | * StaticParam ::= Id Extends? (absorbs unit)? |
|---|
| 1485 | * | int Id |
|---|
| 1486 | * | nat Id |
|---|
| 1487 | * | bool Id |
|---|
| 1488 | * | dim Id |
|---|
| 1489 | * | unit Id (: Type)? (absorbs unit)? |
|---|
| 1490 | * | opr Op |
|---|
| 1491 | * e.g.) EltType extends Number absorbs unit |
|---|
| 1492 | * e.g.) int i |
|---|
| 1493 | * e.g.) nat len |
|---|
| 1494 | * e.g.) bool nan |
|---|
| 1495 | * e.g.) dim D |
|---|
| 1496 | * e.g.) unit U absrbs unit |
|---|
| 1497 | * e.g.) opr ODOT |
|---|
| 1498 | */ |
|---|
| 1499 | StaticParam(IdOrOp name, |
|---|
| 1500 | List<BaseType> extendsClause, |
|---|
| 1501 | Option<Type> dimParam, |
|---|
| 1502 | boolean absorbsParam, |
|---|
| 1503 | StaticParamKind kind, |
|---|
| 1504 | ignoreForEquals boolean lifted = false); |
|---|
| 1505 | /** |
|---|
| 1506 | * name used in declarations and references |
|---|
| 1507 | */ |
|---|
| 1508 | abstract Name(); |
|---|
| 1509 | /** |
|---|
| 1510 | * unstructured sequence of ids naming an API or component |
|---|
| 1511 | * Names in the list must be unqualified. |
|---|
| 1512 | * APIName ::= Id(.Id)* |
|---|
| 1513 | * e.g.) com.sun.fortress.nodes_util |
|---|
| 1514 | * |
|---|
| 1515 | */ |
|---|
| 1516 | APIName(List<Id> ids, ignoreForEquals String text); |
|---|
| 1517 | /** |
|---|
| 1518 | * non-API name |
|---|
| 1519 | * SimpleName ::= Id |
|---|
| 1520 | * | opr Op |
|---|
| 1521 | * | opr EncloserPair |
|---|
| 1522 | */ |
|---|
| 1523 | abstract IdOrOpOrAnonymousName(Option<APIName> apiName); |
|---|
| 1524 | /** |
|---|
| 1525 | * identifier or operator name |
|---|
| 1526 | */ |
|---|
| 1527 | abstract IdOrOp(String text); |
|---|
| 1528 | /** |
|---|
| 1529 | * identifier name |
|---|
| 1530 | * e.g.) hashCode |
|---|
| 1531 | */ |
|---|
| 1532 | Id(); |
|---|
| 1533 | /** |
|---|
| 1534 | * operator name |
|---|
| 1535 | * |
|---|
| 1536 | * Opening and closing Ops must be unqualified. |
|---|
| 1537 | * EncloserPair ::= (LeftEncloser | Encloser) |
|---|
| 1538 | * (RightEncloser | Encloser) |
|---|
| 1539 | * e.g.) COMPOSE |
|---|
| 1540 | * e.g.) === |
|---|
| 1541 | * e.g.) </ /> |
|---|
| 1542 | */ |
|---|
| 1543 | Op(Fixity fixity, boolean enclosing); |
|---|
| 1544 | /** |
|---|
| 1545 | * anonymous name; used internally |
|---|
| 1546 | */ |
|---|
| 1547 | abstract AnonymousName(); |
|---|
| 1548 | /** |
|---|
| 1549 | * internal name for anonymous function expressions |
|---|
| 1550 | * not created during parsing but during evaluation |
|---|
| 1551 | * e.g.) name for "fn x => x + 1" |
|---|
| 1552 | */ |
|---|
| 1553 | AnonymousFnName(); |
|---|
| 1554 | /** |
|---|
| 1555 | * internal name for anonymous constructor expressions |
|---|
| 1556 | * not created during parsing but during evaluation |
|---|
| 1557 | * e.g.) name for "object extends List cons(x) = Cons(x, self) end" |
|---|
| 1558 | */ |
|---|
| 1559 | ConstructorFnName(ObjectConstructor constructor); |
|---|
| 1560 | /** |
|---|
| 1561 | * array comprehension clause |
|---|
| 1562 | * ArrayComprehensionClause ::= ArrayComprehensionLeft | GeneratorClauseList |
|---|
| 1563 | * ArrayComprehensionLeft ::= IdOrInt |-> Expr |
|---|
| 1564 | * | ( IdOrInt, IdOrIntList ) |-> Expr |
|---|
| 1565 | * IdOrInt ::= Id |
|---|
| 1566 | * | IntLiteralExpr |
|---|
| 1567 | * e.g.) (x, y) = 0 | x <- {0, 1, 2}, y <- {0, 1, 2} |
|---|
| 1568 | */ |
|---|
| 1569 | ArrayComprehensionClause(List<Expr> bind, Expr init, |
|---|
| 1570 | List<GeneratorClause> gens); |
|---|
| 1571 | /** |
|---|
| 1572 | * keyword expression used in argument expressions |
|---|
| 1573 | * Names must be unqualified. |
|---|
| 1574 | * KeywordExpr ::= BindId = Expr |
|---|
| 1575 | * e.g.) x = myLoser.myField |
|---|
| 1576 | */ |
|---|
| 1577 | KeywordExpr(Id name, Expr init); |
|---|
| 1578 | /** |
|---|
| 1579 | * case clause used in case expressions and extremum expressions |
|---|
| 1580 | * CaseClause ::= Expr => BlockElems |
|---|
| 1581 | * e.g.) { Jupiter, Saturn, Uranus, Neptune } => "outer" |
|---|
| 1582 | * |
|---|
| 1583 | * <op> |
|---|
| 1584 | * the operator that is used for this particular case. |
|---|
| 1585 | * Created in typechecking, |
|---|
| 1586 | * because different ops can be chosen for different clauses. |
|---|
| 1587 | */ |
|---|
| 1588 | CaseClause(Expr matchClause, Block body, Option<FunctionalRef> op); |
|---|
| 1589 | /** |
|---|
| 1590 | * catch clause used in try expressions |
|---|
| 1591 | * Names must be unqualified. |
|---|
| 1592 | * Catch ::= catch BindId CatchClauses |
|---|
| 1593 | * e.g.) catch e IOException => throw ForbiddenException(e) |
|---|
| 1594 | */ |
|---|
| 1595 | Catch(Id name, List<CatchClause> clauses); |
|---|
| 1596 | /** |
|---|
| 1597 | * each clause in a catch clause used in try expressions |
|---|
| 1598 | * CatchClause ::= TraitType => BlockElems |
|---|
| 1599 | * e.g.) IOException => throw ForbiddenException(e) |
|---|
| 1600 | */ |
|---|
| 1601 | CatchClause(BaseType matchType, Block body); |
|---|
| 1602 | /** |
|---|
| 1603 | * if clause used in if expressions |
|---|
| 1604 | * DelimitedExpr ::= if Expr then BlockElems Elifs? Else? end |
|---|
| 1605 | * Elif ::= elif Expr then BlockElems |
|---|
| 1606 | * e.g.) if x IN { 0, 1, 2 } then 0 |
|---|
| 1607 | */ |
|---|
| 1608 | IfClause(GeneratorClause testClause, Block body); |
|---|
| 1609 | /** |
|---|
| 1610 | * typecase clause used in typecase expressions |
|---|
| 1611 | * TypecaseClause ::= TypecaseTypes => BlockElems |
|---|
| 1612 | * TypecaseTypes ::= ( TypeList ) |
|---|
| 1613 | * | Type |
|---|
| 1614 | * e.g.) String => x.append("foo") |
|---|
| 1615 | */ |
|---|
| 1616 | TypecaseClause(List<Type> matchType, Block body); |
|---|
| 1617 | /** |
|---|
| 1618 | * array and matrix size |
|---|
| 1619 | * ExtentRange ::= StaticArg? # StaticArg? |
|---|
| 1620 | * | StaticArg? : StaticArg? |
|---|
| 1621 | * | StaticArg |
|---|
| 1622 | * e.g.) 3#5 |
|---|
| 1623 | */ |
|---|
| 1624 | ExtentRange(Option<StaticArg> base, |
|---|
| 1625 | Option<StaticArg> size, |
|---|
| 1626 | Option<Op> op); |
|---|
| 1627 | /** |
|---|
| 1628 | * generator |
|---|
| 1629 | * Names must be unqualified. |
|---|
| 1630 | * GeneratorClauseList ::= GeneratorBinding (, GeneratorClause)* |
|---|
| 1631 | * GeneratorBinding ::= BindIdOrBindIdTuple <- Expr |
|---|
| 1632 | * GeneratorClause ::= GeneratorBinding |
|---|
| 1633 | * | Expr |
|---|
| 1634 | * e.g.) (i, j) <- my2DArray.indices |
|---|
| 1635 | */ |
|---|
| 1636 | GeneratorClause(List<Id> bind, Expr init); |
|---|
| 1637 | /** |
|---|
| 1638 | * keyword type used in tuple types |
|---|
| 1639 | * Names must be unqualified. |
|---|
| 1640 | * KeywordType ::= BindId = Type |
|---|
| 1641 | * e.g.) x = String |
|---|
| 1642 | */ |
|---|
| 1643 | KeywordType(Id name, Type keywordType); |
|---|
| 1644 | /** |
|---|
| 1645 | * trait type with a where clause used in extends clauses |
|---|
| 1646 | * TraitTypeWhere ::= TraitType Where? |
|---|
| 1647 | * e.g.) T[\ninf, nan\] where { ninf AND NOT nan } |
|---|
| 1648 | */ |
|---|
| 1649 | TraitTypeWhere(BaseType baseType, Option<WhereClause> whereClause); |
|---|
| 1650 | /** |
|---|
| 1651 | * array dimensionality |
|---|
| 1652 | * ArraySize ::= ExtentRange(, ExtentRange)* |
|---|
| 1653 | * e.g.) 3, 2#1, 3:5 |
|---|
| 1654 | */ |
|---|
| 1655 | Indices(List<ExtentRange> extents); |
|---|
| 1656 | /** |
|---|
| 1657 | * mathematical item |
|---|
| 1658 | */ |
|---|
| 1659 | abstract MathItem() implements OutAfterTypeChecking; |
|---|
| 1660 | /** |
|---|
| 1661 | * mathematical item that is an expression element |
|---|
| 1662 | */ |
|---|
| 1663 | abstract ExprMI(Expr expr); |
|---|
| 1664 | /** |
|---|
| 1665 | * mathematical item that is a parenthesis delimited expression |
|---|
| 1666 | * MathItem ::= ParenthesisDelimited |
|---|
| 1667 | * e.g.) ( 3 + 4 ) |
|---|
| 1668 | */ |
|---|
| 1669 | ParenthesisDelimitedMI(); |
|---|
| 1670 | /** |
|---|
| 1671 | * mathematical item that is not a parenthesis delimited expression |
|---|
| 1672 | * MathItem ::= VarOrFnRef |
|---|
| 1673 | * | LiteralExpr |
|---|
| 1674 | * | self |
|---|
| 1675 | * e.g.) self |
|---|
| 1676 | */ |
|---|
| 1677 | NonParenthesisDelimitedMI(); |
|---|
| 1678 | /** |
|---|
| 1679 | * mathematical item that is a non-expression element |
|---|
| 1680 | */ |
|---|
| 1681 | abstract NonExprMI(); |
|---|
| 1682 | /** |
|---|
| 1683 | * mathematical item that is an exponentiation |
|---|
| 1684 | * MathItem ::= Exponentiation |
|---|
| 1685 | * e.g.) ^3 |
|---|
| 1686 | */ |
|---|
| 1687 | ExponentiationMI(FunctionalRef op, Option<Expr> expr); |
|---|
| 1688 | /** |
|---|
| 1689 | * mathematical item that is a subscripting |
|---|
| 1690 | * MathItem ::= Subscripting |
|---|
| 1691 | * e.g.) [3, 4] |
|---|
| 1692 | */ |
|---|
| 1693 | SubscriptingMI(Op op, List<Expr> exprs, |
|---|
| 1694 | List<StaticArg> staticArgs); |
|---|
| 1695 | |
|---|
| 1696 | /** |
|---|
| 1697 | * One of possibly many overloadings for some function application. |
|---|
| 1698 | */ |
|---|
| 1699 | Overloading(IdOrOp unambiguousName, |
|---|
| 1700 | IdOrOp originalName, |
|---|
| 1701 | Option<ArrowType> type, |
|---|
| 1702 | Option<ArrowType> schema = Option.<ArrowType>none()); |
|---|
| 1703 | |
|---|
| 1704 | /** syntactic abstraction nodes ************************************/ |
|---|
| 1705 | |
|---|
| 1706 | /** |
|---|
| 1707 | * nonterminal header |
|---|
| 1708 | */ |
|---|
| 1709 | NonterminalHeader(Modifiers mods, // Only Modifiers.Private is allowed |
|---|
| 1710 | Id name, |
|---|
| 1711 | List<NonterminalParameter> params, |
|---|
| 1712 | List<StaticParam> staticParams, |
|---|
| 1713 | Option<Type> paramType, |
|---|
| 1714 | Option<WhereClause> whereClause); |
|---|
| 1715 | |
|---|
| 1716 | /** |
|---|
| 1717 | * nonterminal parameter |
|---|
| 1718 | */ |
|---|
| 1719 | NonterminalParameter(Id name, BaseType paramType); |
|---|
| 1720 | |
|---|
| 1721 | /** |
|---|
| 1722 | * syntax declaration |
|---|
| 1723 | */ |
|---|
| 1724 | abstract SyntaxDecl(Option<String> modifier); |
|---|
| 1725 | /** |
|---|
| 1726 | * syntax definition in syntax declarations |
|---|
| 1727 | */ |
|---|
| 1728 | SyntaxDef(List<SyntaxSymbol> syntaxSymbols, |
|---|
| 1729 | TransformerDecl transformer); |
|---|
| 1730 | |
|---|
| 1731 | SuperSyntaxDef(Id nonterminal, Id grammarId); |
|---|
| 1732 | |
|---|
| 1733 | /** |
|---|
| 1734 | * Transformation declaration |
|---|
| 1735 | */ |
|---|
| 1736 | abstract TransformerDecl(); |
|---|
| 1737 | /** |
|---|
| 1738 | * pre transformer definition in transformer declarations |
|---|
| 1739 | */ |
|---|
| 1740 | PreTransformerDef(Transformer transformer); |
|---|
| 1741 | /** |
|---|
| 1742 | * transformer definition in transformer declarations |
|---|
| 1743 | */ |
|---|
| 1744 | NamedTransformerDef(String name, List<NonterminalParameter> parameters, Transformer transformer); |
|---|
| 1745 | |
|---|
| 1746 | /** |
|---|
| 1747 | * Transformers |
|---|
| 1748 | */ |
|---|
| 1749 | abstract Transformer(); |
|---|
| 1750 | /** |
|---|
| 1751 | * Unparsed template |
|---|
| 1752 | */ |
|---|
| 1753 | UnparsedTransformer(String transformer, Id nonterminal); |
|---|
| 1754 | /** |
|---|
| 1755 | * Parsed template |
|---|
| 1756 | */ |
|---|
| 1757 | NodeTransformer(AbstractNode node); |
|---|
| 1758 | /** |
|---|
| 1759 | * Case-dispatch transformer expr |
|---|
| 1760 | */ |
|---|
| 1761 | CaseTransformer(Id gapName, List<CaseTransformerClause> clauses); |
|---|
| 1762 | |
|---|
| 1763 | /** |
|---|
| 1764 | * Case transformer clause |
|---|
| 1765 | */ |
|---|
| 1766 | CaseTransformerClause(Id constructor, List<Id> parameters, Transformer body); |
|---|
| 1767 | |
|---|
| 1768 | /** |
|---|
| 1769 | * syntax symbol |
|---|
| 1770 | */ |
|---|
| 1771 | abstract SyntaxSymbol(); |
|---|
| 1772 | /** |
|---|
| 1773 | * prefixed syntax symbol |
|---|
| 1774 | */ |
|---|
| 1775 | PrefixedSymbol(Id id, SyntaxSymbol symbol); |
|---|
| 1776 | /** |
|---|
| 1777 | * optional syntax symbol |
|---|
| 1778 | */ |
|---|
| 1779 | OptionalSymbol(SyntaxSymbol symbol); |
|---|
| 1780 | /** |
|---|
| 1781 | * repeat zero-or-more syntax symbol |
|---|
| 1782 | */ |
|---|
| 1783 | RepeatSymbol(SyntaxSymbol symbol); |
|---|
| 1784 | /** |
|---|
| 1785 | * repeat one-or-more syntax symbol |
|---|
| 1786 | */ |
|---|
| 1787 | RepeatOneOrMoreSymbol(SyntaxSymbol symbol); |
|---|
| 1788 | /** |
|---|
| 1789 | * ignore following whitespace syntax symbol |
|---|
| 1790 | */ |
|---|
| 1791 | NoWhitespaceSymbol(SyntaxSymbol symbol); |
|---|
| 1792 | /** |
|---|
| 1793 | * groups of symbols |
|---|
| 1794 | */ |
|---|
| 1795 | GroupSymbol(List<SyntaxSymbol> symbols); |
|---|
| 1796 | /** |
|---|
| 1797 | * special symbols syntax symbol |
|---|
| 1798 | */ |
|---|
| 1799 | abstract SpecialSymbol(); |
|---|
| 1800 | /** |
|---|
| 1801 | * any character syntax symbol |
|---|
| 1802 | */ |
|---|
| 1803 | AnyCharacterSymbol(); |
|---|
| 1804 | /** |
|---|
| 1805 | * whitespace syntax symbol |
|---|
| 1806 | */ |
|---|
| 1807 | WhitespaceSymbol(String s); |
|---|
| 1808 | /** |
|---|
| 1809 | * tab syntax symbol |
|---|
| 1810 | */ |
|---|
| 1811 | TabSymbol(); |
|---|
| 1812 | /** |
|---|
| 1813 | * formfeed syntax symbol |
|---|
| 1814 | */ |
|---|
| 1815 | FormfeedSymbol(); |
|---|
| 1816 | /** |
|---|
| 1817 | * carriage return syntax symbol |
|---|
| 1818 | */ |
|---|
| 1819 | CarriageReturnSymbol(); |
|---|
| 1820 | /** |
|---|
| 1821 | * backspace syntax symbol |
|---|
| 1822 | */ |
|---|
| 1823 | BackspaceSymbol(); |
|---|
| 1824 | /** |
|---|
| 1825 | * newline syntax symbol |
|---|
| 1826 | */ |
|---|
| 1827 | NewlineSymbol(); |
|---|
| 1828 | /** |
|---|
| 1829 | * breakline syntax symbol |
|---|
| 1830 | */ |
|---|
| 1831 | BreaklineSymbol(String s); |
|---|
| 1832 | /** |
|---|
| 1833 | * item syntax symbol; |
|---|
| 1834 | * may be either nonterminal or keyword |
|---|
| 1835 | */ |
|---|
| 1836 | ItemSymbol(String item); |
|---|
| 1837 | /** |
|---|
| 1838 | * non-terminal syntax symbol |
|---|
| 1839 | */ |
|---|
| 1840 | NonterminalSymbol(Id nonterminal); |
|---|
| 1841 | /** |
|---|
| 1842 | * keyword syntax symbol |
|---|
| 1843 | */ |
|---|
| 1844 | KeywordSymbol(String token); |
|---|
| 1845 | /** |
|---|
| 1846 | * token syntax symbol |
|---|
| 1847 | */ |
|---|
| 1848 | TokenSymbol(String token); |
|---|
| 1849 | /** |
|---|
| 1850 | * not predicate syntax symbol |
|---|
| 1851 | */ |
|---|
| 1852 | NotPredicateSymbol(SyntaxSymbol symbol); |
|---|
| 1853 | /** |
|---|
| 1854 | * and predicate syntax symbol |
|---|
| 1855 | */ |
|---|
| 1856 | AndPredicateSymbol(SyntaxSymbol symbol); |
|---|
| 1857 | /** |
|---|
| 1858 | * character class syntax symbol |
|---|
| 1859 | */ |
|---|
| 1860 | CharacterClassSymbol(List<CharacterSymbol> characters); |
|---|
| 1861 | /** |
|---|
| 1862 | * character symbols |
|---|
| 1863 | */ |
|---|
| 1864 | abstract CharacterSymbol(); |
|---|
| 1865 | /** |
|---|
| 1866 | * character |
|---|
| 1867 | */ |
|---|
| 1868 | CharSymbol(String string); |
|---|
| 1869 | /** |
|---|
| 1870 | * character interval |
|---|
| 1871 | */ |
|---|
| 1872 | CharacterInterval(String beginSymbol, String endSymbol); |
|---|
| 1873 | /* |
|---|
| 1874 | * A Link in a ChainExpr is a pair of FunctionalRef and the next Expr in the chain. |
|---|
| 1875 | * e.g.) < 5 |
|---|
| 1876 | */ |
|---|
| 1877 | Link(FunctionalRef op, Expr expr); |
|---|
| 1878 | |
|---|
| 1879 | /** |
|---|
| 1880 | * top-level information interface |
|---|
| 1881 | */ |
|---|
| 1882 | interface Info(); |
|---|
| 1883 | /** |
|---|
| 1884 | * node introduced or eliminated after a compiler phase |
|---|
| 1885 | */ |
|---|
| 1886 | interface InOutPhases(); |
|---|
| 1887 | /** |
|---|
| 1888 | * introduced after the type checking phase |
|---|
| 1889 | */ |
|---|
| 1890 | interface InAfterTypeChecking(); |
|---|
| 1891 | /** |
|---|
| 1892 | * eliminated after the type checking phase |
|---|
| 1893 | */ |
|---|
| 1894 | interface OutAfterTypeChecking(); |
|---|
| 1895 | /** |
|---|
| 1896 | * left-hand-side of assignments, local variable declarations, or |
|---|
| 1897 | * top-level variable declarations |
|---|
| 1898 | */ |
|---|
| 1899 | interface Lhs(); |
|---|
| 1900 | /** |
|---|
| 1901 | * functional declaration or function expression |
|---|
| 1902 | * nodes_util.NodeUtil declares the following static methods: |
|---|
| 1903 | * - String nameAsMethod(Applicable) |
|---|
| 1904 | * - Option<Expr> getBody(Applicable) |
|---|
| 1905 | */ |
|---|
| 1906 | interface Applicable(FnHeader header); |
|---|
| 1907 | /** |
|---|
| 1908 | * templates |
|---|
| 1909 | */ |
|---|
| 1910 | interface TemplateGap(Id gapId, List<Id> templateParams); |
|---|
| 1911 | /** |
|---|
| 1912 | * A syntax transformation |
|---|
| 1913 | */ |
|---|
| 1914 | interface _SyntaxTransformation(String syntaxTransformer, |
|---|
| 1915 | Map<String,Level> variables, |
|---|
| 1916 | List<String> syntaxParameters); |
|---|
| 1917 | /** |
|---|
| 1918 | * Repeated expression inside a syntax transformation template |
|---|
| 1919 | */ |
|---|
| 1920 | interface _Ellipses(AbstractNode repeatedNode); |
|---|
| 1921 | /* |
|---|
| 1922 | * root class for information nodes |
|---|
| 1923 | */ |
|---|
| 1924 | abstract InfoNode() extends UIDObject; |
|---|
| 1925 | /** |
|---|
| 1926 | * with fields to be emitted to the cached files |
|---|
| 1927 | */ |
|---|
| 1928 | abstract DataNode(); |
|---|
| 1929 | /** |
|---|
| 1930 | * with static parameters |
|---|
| 1931 | */ |
|---|
| 1932 | abstract GenericHeader(List<StaticParam> staticParams); |
|---|
| 1933 | /** |
|---|
| 1934 | * common header for trait/object/function declaration/expression |
|---|
| 1935 | */ |
|---|
| 1936 | abstract DeclHeader(Modifiers mods, // except FnExpr |
|---|
| 1937 | IdOrOpOrAnonymousName name, |
|---|
| 1938 | Option<WhereClause> whereClause, |
|---|
| 1939 | Option<List<Type>> throwsClause, // except TraitDecl |
|---|
| 1940 | Option<Contract> contract); // except TraitDecl / FnExpr |
|---|
| 1941 | /** |
|---|
| 1942 | * common header for trait/object declaration/expression |
|---|
| 1943 | */ |
|---|
| 1944 | TraitTypeHeader(List<TraitTypeWhere> extendsClause, |
|---|
| 1945 | List<Decl> decls); |
|---|
| 1946 | /** |
|---|
| 1947 | * common header for function declaration/expression |
|---|
| 1948 | */ |
|---|
| 1949 | FnHeader(List<Param> params, Option<Type> returnType); |
|---|
| 1950 | /** |
|---|
| 1951 | * common header for AST nodes |
|---|
| 1952 | */ |
|---|
| 1953 | abstract ASTNodeInfo(ignoreForEquals Span span); |
|---|
| 1954 | /** |
|---|
| 1955 | * common header for node with Span |
|---|
| 1956 | */ |
|---|
| 1957 | SpanInfo(); |
|---|
| 1958 | /** |
|---|
| 1959 | * common header for parenthesized node |
|---|
| 1960 | */ |
|---|
| 1961 | abstract ParenthesizedInfo(ignoreForEquals boolean parenthesized); |
|---|
| 1962 | /** |
|---|
| 1963 | * common header for expressions |
|---|
| 1964 | */ |
|---|
| 1965 | ExprInfo(ignoreForEquals Option<Type> exprType); |
|---|
| 1966 | /** |
|---|
| 1967 | * common header for types |
|---|
| 1968 | */ |
|---|
| 1969 | TypeInfo(List<StaticParam> staticParams, |
|---|
| 1970 | Option<WhereClause> whereClause); |
|---|
| 1971 | /* |
|---|
| 1972 | * Contains info about the self parameter in an arrow type for |
|---|
| 1973 | * a method. `selfPosition` is -1 for dotted methods, and a |
|---|
| 1974 | * 0-based index into the params for functional methods. |
|---|
| 1975 | */ |
|---|
| 1976 | MethodInfo(Type selfType, int selfPosition); |
|---|
| 1977 | /** |
|---|
| 1978 | * Metadata for each constituent assignment in an assignment |
|---|
| 1979 | * expression. `opForLhs` contains the FunctionalRef representing |
|---|
| 1980 | * the actual checked operator for this compound assignment. |
|---|
| 1981 | * `compoundCoercionOuter` holds the coercion for the outer |
|---|
| 1982 | * compound OpExpr. `compoundCoercionInner` holds the coercion |
|---|
| 1983 | * for the occurence of the LHS within the OpExpr. |
|---|
| 1984 | */ |
|---|
| 1985 | CompoundAssignmentInfo(FunctionalRef opForLhs, |
|---|
| 1986 | Option<CoercionInvocation> compoundCoercionOuter, |
|---|
| 1987 | Option<CoercionInvocation> compoundCoercionInner); |
|---|
| 1988 | /* |
|---|
| 1989 | * Keeps track of ellipses properties. This is special cased |
|---|
| 1990 | * in the Printer and UnPrinter so be careful if Level is changed. |
|---|
| 1991 | */ |
|---|
| 1992 | Level(int level, Object _object); |
|---|
| 1993 | /** |
|---|
| 1994 | * operator fixity |
|---|
| 1995 | */ |
|---|
| 1996 | abstract Fixity(); |
|---|
| 1997 | /** |
|---|
| 1998 | * e.g.) 3 + 5 |
|---|
| 1999 | */ |
|---|
| 2000 | InFixity(); |
|---|
| 2001 | /** |
|---|
| 2002 | * e.g.) -5 |
|---|
| 2003 | */ |
|---|
| 2004 | PreFixity(); |
|---|
| 2005 | /** |
|---|
| 2006 | * e.g.) 3! |
|---|
| 2007 | */ |
|---|
| 2008 | PostFixity(); |
|---|
| 2009 | /** |
|---|
| 2010 | * e.g.) : |
|---|
| 2011 | */ |
|---|
| 2012 | NoFixity(); |
|---|
| 2013 | /** |
|---|
| 2014 | * e.g.) S1 BY S2 BY S3 |
|---|
| 2015 | */ |
|---|
| 2016 | MultiFixity(); |
|---|
| 2017 | /** |
|---|
| 2018 | * left encloser or right encloser |
|---|
| 2019 | * e.g.) <| |
|---|
| 2020 | */ |
|---|
| 2021 | EnclosingFixity(); |
|---|
| 2022 | /** |
|---|
| 2023 | * BIG operator |
|---|
| 2024 | * e.g.) SUM |
|---|
| 2025 | */ |
|---|
| 2026 | BigFixity(); |
|---|
| 2027 | /** |
|---|
| 2028 | * Fixity is not yet known |
|---|
| 2029 | * This should not appear after parsing. |
|---|
| 2030 | */ |
|---|
| 2031 | UnknownFixity(); |
|---|
| 2032 | /** |
|---|
| 2033 | * static parameters |
|---|
| 2034 | */ |
|---|
| 2035 | abstract StaticParamKind(); |
|---|
| 2036 | /** |
|---|
| 2037 | * type parameter |
|---|
| 2038 | * e.g.) EltType extends Number absorbs unit |
|---|
| 2039 | */ |
|---|
| 2040 | KindType(); |
|---|
| 2041 | /** |
|---|
| 2042 | * int parameter |
|---|
| 2043 | * e.g.) int i |
|---|
| 2044 | */ |
|---|
| 2045 | KindInt(); |
|---|
| 2046 | /** |
|---|
| 2047 | * nat parameter |
|---|
| 2048 | * e.g.) nat len |
|---|
| 2049 | */ |
|---|
| 2050 | KindNat(); |
|---|
| 2051 | /** |
|---|
| 2052 | * bool parameter |
|---|
| 2053 | * e.g.) bool nan |
|---|
| 2054 | */ |
|---|
| 2055 | KindBool(); |
|---|
| 2056 | /** |
|---|
| 2057 | * dim parameter |
|---|
| 2058 | * e.g.) dim D |
|---|
| 2059 | */ |
|---|
| 2060 | KindDim(); |
|---|
| 2061 | /** |
|---|
| 2062 | * unit parameter |
|---|
| 2063 | * e.g.) unit U absrbs unit |
|---|
| 2064 | */ |
|---|
| 2065 | KindUnit(); |
|---|
| 2066 | /** |
|---|
| 2067 | * operator parameter |
|---|
| 2068 | * e.g.) opr ODOT |
|---|
| 2069 | */ |
|---|
| 2070 | KindOp(); |
|---|
| 2071 | |
|---|
| 2072 | end; |
|---|