A "high-level" language for the Gameboy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
696 B

  1. export type Program = Array<Decl | Stmt>
  2. // Declarations
  3. export type Decl = VarDecl
  4. export type VarDecl = ADecl<"var", {
  5. type: Type,
  6. }>
  7. type ADecl<Ty, Args> = {
  8. type: "decl",
  9. decl_type: Ty,
  10. attrs: Array<Attr>,
  11. name: string,
  12. args: Args,
  13. }
  14. // Statements
  15. export type Stmt = AssignStmt
  16. export type AssignStmt = AStmt<"assign", {
  17. name: string,
  18. expr: Expr,
  19. }>
  20. type AStmt<Ty, Args> = {
  21. type: "stmt",
  22. stmt_type: Ty,
  23. args: Args,
  24. }
  25. // Expressions
  26. export type Expr = number
  27. // Attributes
  28. export type Attr = {
  29. name: string,
  30. args: Array<string | number>,
  31. }
  32. // Types
  33. export type Type = PrimitiveType
  34. export type PrimitiveType = "s8" | "u8" | "u16"