Skip to content

Instantly share code, notes, and snippets.

@okram
Created September 22, 2020 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okram/bd38ba9def65ab57a4ba8897b7b19280 to your computer and use it in GitHub Desktop.
Save okram/bd38ba9def65ab57a4ba8897b7b19280 to your computer and use it in GitHub Desktop.
lazy val cType:Parser[Obj] = (anonType | boolType | realType | intType | strType | instType | (not(inst) ~> (lstType | recType)) | tokenType) ~ opt(quantifier) ^^ (x => x._2.map(q => x._1.q(q)).getOrElse(x._1))
lazy val dtype:Parser[Obj] = cType ~ rep[Inst[Obj, Obj]](inst) ^^ (x => x._2.foldLeft(x._1.asInstanceOf[Obj])((x, y) => y.exec(x))) | anonTypeSugar
// the top definition of a type
lazy val aType:Parser[Obj] = opt(cType <~ Tokens.:<=) ~ dtype ^^ {
case Some(range) ~ domain => range <= domain
case None ~ domain => domain
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment