Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created April 22, 2014 13:15
Show Gist options
  • Save pasberth/11178755 to your computer and use it in GitHub Desktop.
Save pasberth/11178755 to your computer and use it in GitHub Desktop.
Procedural example

procedural.lthstx というファイルで構文を定義しています。 まだ処理系は公開していませんが、現在これが期待した通りに動作するよう実装できています。

構文は完全に宣言的に定義されているので、それ自体が構文仕様になります。

_ = require "underscore";
console.log _.shuffle Array 1, 2, 3
Token "."
Token ";"
Token ","
Notation "$a ; $b" := "@SEQUENCE $a $b"
level 0 right associativity
Notation "$a . $b" := "@MEMBER $a $b"
level 2000 left associativity
Notation "$a , $b" := "@ORDERED-PAIR $a $b"
level 1900 right associativity
Notation "$a = $b" := "@ASSIGN $a $b"
level 100 right associativity
Notation "($a)" := "$a"
level 2000 no associativity
Notation "do $a end" := "$a"
level 2000 no associativity
Notation "$a $b" := "$a $b"
level 1900 right associativity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment