OILS / demo / houston-fp / demo.asdl View on Github | oilshell.org

32 lines, 15 significant
1# Show off "first class variants" / case classes.
2#
3# Takeaways:
4# - metalanguage affects the language
5# - metalanguage design / code compression
6
7# Based on frontend/syntax.asdl
8
9module demo {
10
11 # Product type
12 Token = (int id, int length, int col, str line)
13
14 word_part =
15 Literal %Token
16 | TildeSub(str? user_name)
17
18 value =
19 Int(int i)
20 | Str(str s)
21
22 expr =
23 Var %Token # a variable name to evaluate
24 | Const(Token c, value val)
25
26 # Source location for errors
27 loc =
28 Missing
29 | Token %Token
30 # Another example from Oils
31 #| ArgWord %CompoundWord
32}