From be77dbbfac6783d277b3e7ee159651ad5aea7e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sta=C5=9B=20Ma=C5=82olepszy?= Date: Wed, 18 Jan 2017 19:13:55 +0100 Subject: [PATCH] Add ASDL description of the Fluent syntax. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- fluent.asdl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 fluent.asdl diff --git a/fluent.asdl b/fluent.asdl new file mode 100644 index 0000000..cc1011d --- /dev/null +++ b/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) +}