OILS / asdl / examples / typed_demo.asdl View on Github | oilshell.org

49 lines, 34 significant
1-- To test how all ASDL construct generate typed code.
2
3module arith {
4 use asdl examples demo_lib { value }
5
6 -- Simple Sum Type
7 op_id = Plus | Minus | Star
8
9 op_array = (op_id* ops)
10 assign = (string name, string* flags)
11
12 -- Compound Sum Type
13 cflow =
14 Break
15 | Continue
16 | Return(int status)
17
18 source_location = (string path, int line, int col, int length)
19
20 word = (string value)
21
22 bool_expr =
23 Binary(word left, word right)
24 | Unary(word child)
25 | LogicalNot(bool_expr b)
26 | LogicalBinary(op_id op, bool_expr left, bool_expr right)
27
28 Token = (string s, bool b)
29 cflow2 = Break | Continue | Return(int status)
30
31 Dicts = (
32 Dict[string, string] ss,
33 Dict[int, bool] ib,
34
35 -- This has a user-defined type
36 Dict[string, Token] tokens,
37 )
38
39 flag_type = Bool | Int | Float | Str | Enum(string* alts)
40
41 SetToArg_ = (string name, flag_type flag_type, bool quit_parsing_flags)
42
43 -- Test defaults
44 Strings = (string required, string? optional)
45
46 Maybes = (Token? op, word? arg)
47
48 OptionalList = (List[word]? words)
49}