Skip to content

Commit be77dbb

Browse files
committed
Add ASDL description of the Fluent syntax.
ASDL is a language for describing ASTs. It's a bit like structs and enums, but more concise and language-agnostic. It's different from (E)BNF in that it doens't describe the grammar—but rather the data structure that can be used by a compiler or an interpreter. References: "The Zephyr Abstract Syntax Description Language" ftp://ftp.cs.princeton.edu/techreports/1997/554.pdf "Design of CPython’s Compiler" https://docs.python.org/devguide/compiler.html Using ASDL to describe ASTs in compilers http://eli.thegreenplace.net/2014/06/04/using-asdl-to-describe-asts-in-compilers "What is Zephyr ASDL?" http://www.oilshell.org/blog/2016/12/11.html
1 parent 79fadb1 commit be77dbb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

fluent.asdl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module Fluent
2+
{
3+
res = Resource(entry* body, comment? comment)
4+
5+
entry = Message(iden id, pat? value, mem* traits, comment? comment)
6+
| Section(key key, entry* body, comment? comment)
7+
| Comment(comment)
8+
| Junk(string body)
9+
10+
pat = Pattern(elem* elements, bool quoted)
11+
elem = Text(string)
12+
| Placeable(expr* expressions)
13+
14+
expr = MessageReference(iden id)
15+
| ExternalArgument(iden id)
16+
| CallExpression(iden callee, expr* args)
17+
| SelectExpression(expr exp, mem* vars)
18+
| MemberExpression(expr obj, memkey key)
19+
| KeyValueArgument(iden name, expr* val)
20+
| Number(string value)
21+
| String(string value)
22+
23+
mem = Member(memkey key, pat value, bool default)
24+
memkey = Number(string value)
25+
| Keyword(iden? ns, key name)
26+
27+
iden = (string name)
28+
key = (string name)
29+
30+
comment = (string body)
31+
}

0 commit comments

Comments
 (0)