All Downloads are FREE. Search and download functionalities are using the official Maven repository.

defs.main-tests.source.idltest.ast.domain Maven / Gradle / Ivy

The newest version!
domain idltest.ast

// ast ADT
// small language copied from
//   https://gist.github.com/gatlin/c56a12abc386fc9df498ec2d7292a9a5

// untyped AST
adt AST {
  IntNode
  FloatNode as FloatRenamed
  BoolNode
  SymNode
  AppNode
  LamNode
  IfNode
}

mixin IntNode {
  lit: i32
}

mixin FloatNode {
  lit: flt
}

mixin BoolNode {
  lit: bool
}

mixin SymNode {
  lit: str
}

mixin AppNode {
  fun: opt[AST]
  args: list[AST]
}

mixin LamNode {
  paramNames: list[str]
  body: opt[AST]
}

mixin IfNode {
  cond: opt[AST]
  thenNode: opt[AST]
  elseNode: opt[AST]
}

// typed AST

data Type {
  label: str
}

mixin TypeInfo {
  tpe: Type
}

adt TypedAst {
  TIntNode
  TFloatNode
  TBoolNode
  TSymNode
  TAppNode
  TLamNode
  TIfNode
}

mixin TIntNode {
  & IntNode
  + TypeInfo
}

mixin TFloatNode {
  & FloatNode
  + TypeInfo
}

mixin TBoolNode {
  & BoolNode
  + TypeInfo
}

mixin TSymNode {
  & SymNode
  + TypeInfo
}

mixin TAppNode {
  & AppNode
  + TypeInfo
}

mixin TLamNode {
  & LamNode
  + TypeInfo
}

mixin TIfNode {
  & IfNode
  + TypeInfo
}

// Aliased (with reserved keywords as aliases)
adt AliasedAdt {
    EventData as event
    PublicData as public
}

data EventData {
}

data PublicData {
}















© 2015 - 2025 Weber Informatics LLC | Privacy Policy