OILS / mycpp / examples / expr.asdl View on Github | oils.pub

59 lines, 17 significant
1module expr {
2
3tok =
4 Const
5 | Var
6 | Op1
7 | Op2
8 | Paren
9 | Eof
10 | Invalid
11
12expr =
13 Const(int i)
14 | Var(string name)
15 | Binary(string op, expr left, expr right)
16
17# Subtype Optimization
18
19CompoundWord < List[str]
20
21# Leaf Struct Value Optimization
22#
23# It's only different in C++
24#
25# What is affected?
26#
27# *** ASDL:
28#
29# (1) ASDL Schema Validation
30# - The Measure_v can't contain any pointers, because otherwise the GC
31# header would be wrong.
32#
33# (2) GC header for structs that contain it, like MeasuredDoc
34# They will simply IGNORE its presence
35#
36# (3) Class definition
37# - There will be no CreateNull(), because it calls Alloc()
38# - There will be no DISALLOW_COPY_AND_ASSIGN(), because that's precisely
39# what we want
40#
41# *** mycpp:
42#
43# (1) Initialization (and local var rooting)
44# m = Measure_v(3, 4) # don't do Alloc<Measure_v>()
45#
46# (2) Types - Measure_v instead of Measure_v* everywhere
47# local var types -
48# func param types
49# func return types
50#
51# (3) Attribute access
52# mdoc.measure instead of mdoc->measure
53
54Measure_v = (int a, int b)
55
56# The GC header is affected
57MeasuredDoc = (str s, Measure_v measure)
58
59}