From 7e634a3581caa1cc9d7c53314c6c8242f1792f27 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 7 Aug 2009 18:37:36 +0200 Subject: Add formal language spec for the first iteration --- doc/language.txt | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 doc/language.txt (limited to 'doc') diff --git a/doc/language.txt b/doc/language.txt new file mode 100644 index 0000000..6000925 --- /dev/null +++ b/doc/language.txt @@ -0,0 +1,88 @@ +@@ No support for template ids +@@ No support for expressions (e.g., 2*2) + +Token types: + keyword + identifier + punctuation (";" "{" "}" "(" ")" "," "|" "=" ":") + bracket-literal + string-literal + bool-literal + int-literal + float-literal + end-of-stream + +def-unit: + include-decl-seq(opt) decl-seq(opt) + +include-decl-seq: + include-decl + include-decl-seq include-decl; + +include-decl: + "include" path ";" + +path: + string-literal + bracket-literal + +decl-seq: + decl + decl-seq decl + +decl: + namespace-def + class-def + +namespace-def: + "namespace" identifier "{" namespace-body "}" + +namespace-body: + decl-seq(opt) + +class-def: + "class" identifier "{" option-def-seq(opt) "};" + +option-def-seq: + option-def + option-def-seq option-def + +option-def: + type-spec option-name-seq initializer(opt) ";" + +type-spec: + fundamental-type-spec + qualified-name + +option-name-seq: + option-name + option-name-seq "|" option-name; + +option-name: + identifier + string-literal + +initializer: + "=" argument-expr + "(" argument-seq(opt) ")" + +argument-seq: + argument-expr + argument-seq "," argument-expr + +argument-expr + bool-literal + int-literal + float-literal + string-literal + qualified-name + +qualified-name: + identifier + qualified-name "::" identifier + +fundamental-type-spec + "bool" + ... + "long double" + -- cgit v1.1