summaryrefslogtreecommitdiff
path: root/src/compiler/SimpleEditor/Syntax.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-02-21 16:58:18 +0000
committerhallgren <hallgren@chalmers.se>2012-02-21 16:58:18 +0000
commit2eddc116e676b249d300e930263255bfab057622 (patch)
tree83102f3dc9445701ffeb3444722558b5398ac6a6 /src/compiler/SimpleEditor/Syntax.hs
parent5403e31264f25c5a2d93d978a6a2ed66eb9a1929 (diff)
gfse: edit abstract syntax in text mode with instant syntax error reporting
This is an experimental feature. It requires server support for parsing and is thus not available while offline, unlike most other editing functionality.
Diffstat (limited to 'src/compiler/SimpleEditor/Syntax.hs')
-rw-r--r--src/compiler/SimpleEditor/Syntax.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/compiler/SimpleEditor/Syntax.hs b/src/compiler/SimpleEditor/Syntax.hs
new file mode 100644
index 000000000..4a5eb6da8
--- /dev/null
+++ b/src/compiler/SimpleEditor/Syntax.hs
@@ -0,0 +1,39 @@
+{-
+Abstract syntax for the small subset of GF grammars supported
+in gfse, the JavaScript-based simple grammar editor.
+-}
+module SimpleEditor.Syntax where
+
+type Id = String -- all sorts of identifiers
+type ModId = Id -- module name
+type Cat = Id -- category name
+type FunId = Id -- function name
+type Type = [Cat] -- [Cat_1,...,Cat_n] means Cat_1 -> ... -> Cat_n
+
+data Grammar = Grammar { basename :: ModId,
+ extends :: [ModId],
+ abstract :: Abstract,
+ concretes:: [Concrete] }
+ deriving Show
+
+data Abstract = Abstract { startcat:: Cat, cats:: [Cat], funs:: [Fun] }
+ deriving Show
+data Fun = Fun { fname:: FunId, ftype:: Type }
+ deriving Show
+
+data Concrete = Concrete { langcode:: Id,
+ opens:: [ModId],
+ params:: [Param],
+ lincats:: [Lincat],
+ opers:: [Oper],
+ lins:: [Lin] }
+ deriving Show
+
+data Param = Param {pname:: Id, prhs:: String} deriving Show
+data Lincat = Lincat {cat :: Cat, lintype:: Term} deriving Show
+data Oper = Oper {oname:: Lhs, orhs:: Term} deriving Show
+data Lin = Lin {fun :: FunId, args:: [Id], lin:: Term} deriving Show
+
+type Lhs = String -- name and type of oper,
+ -- e.g "regN : Str -> { s:Str,g:Gender} ="
+type Term = String -- arbitrary GF term (not parsed by the editor)