-
-
Save ochafik/32b8dc4e2a4edee3fc42 to your computer and use it in GitHub Desktop.
dart parser.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Test extends App { | |
| var tot = 0 | |
| val n = args.length * 2 | |
| for (i <- 0 to 10) { | |
| tot += i | |
| print(tot); | |
| } | |
| } | |
| case class Pos(source: String, offset: Long) | |
| case class Node[A]( | |
| value: A, | |
| pos: Option[Pos], | |
| sym: Option[Symbol], | |
| tpe: Option[Type]) | |
| sealed trait Type | |
| sealed trait Symbol { | |
| var tpe: Option[Type] = None | |
| } | |
| sealed trait Tree | |
| trait Expr extends Tree | |
| trait ConstantExpr extends Expr | |
| case class ConstantScalarExpr(value: Any) extends ConstantExpr | |
| trait ListExprLike { | |
| def values: List[Node[ConstantExpr]] | |
| } | |
| case class ListExpr(values: List[Node[ConstantExpr]]) extends Expr with ListExprLike | |
| case class ConstantListExpr(values: List[Node[ConstantExpr]]) extends ConstantExpr with ListExprLike | |
| trait MapExprLike { | |
| def values: List[(Node[ConstantExpr], Node[ConstantExpr])] | |
| } | |
| case class MapExpr(values: List[(Node[ConstantExpr], Node[ConstantExpr])]) extends Expr with MapExprLike | |
| case class ConstantMapExpr(values: List[(Node[ConstantExpr], Node[ConstantExpr])]) extends ConstantExpr with MapExprLike | |
| sealed trait Phase | |
| // Populates symbols, does lexical resolution (insertion of "this."...) | |
| class Resolution extends Phase | |
| // Tag symbols with types | |
| class Typing extends Phase | |
| // Adding runtime type checks if needed | |
| class TypechecksInsertion extends Phase | |
| // Gathering of all potential method calls, creation of noSuchMethod-enabled base class (JavaScriptBlobTree) | |
| class BaseClassGeneration extends Phase | |
| // - Operators renaming, | |
| // - == -> operator== or === (for primitives), | |
| // - throw on null cast to boolean | |
| // - class syntax -> Object.defineProperties | |
| // - field initializers -> constructors | |
| // - constructors -> static methods | |
| class Dart2JavaScriptSemanticsTransformation extends Phase | |
| // Unparsing: only output JavaScriptBlobTrees | |
| class Unparsing | |
| class C { | |
| var x = 10; | |
| var y = 0.0 | |
| def foo(z: (Int, Int)): Double = x + y + z._1 + z._2; | |
| def foo(x: Int, y: ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment