Skip to content

Commit

Permalink
Add ASDL description of the Fluent syntax.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stasm committed Jan 18, 2017
1 parent 79fadb1 commit be77dbb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions fluent.asdl
@@ -0,0 +1,31 @@
module Fluent
{
res = Resource(entry* body, comment? comment)

entry = Message(iden id, pat? value, mem* traits, comment? comment)
| Section(key key, entry* body, comment? comment)
| Comment(comment)
| Junk(string body)

pat = Pattern(elem* elements, bool quoted)
elem = Text(string)
| Placeable(expr* expressions)

expr = MessageReference(iden id)
| ExternalArgument(iden id)
| CallExpression(iden callee, expr* args)
| SelectExpression(expr exp, mem* vars)
| MemberExpression(expr obj, memkey key)
| KeyValueArgument(iden name, expr* val)
| Number(string value)
| String(string value)

mem = Member(memkey key, pat value, bool default)
memkey = Number(string value)
| Keyword(iden? ns, key name)

iden = (string name)
key = (string name)

comment = (string body)
}

0 comments on commit be77dbb

Please sign in to comment.