summaryrefslogtreecommitdiff
path: root/src/compiler/SimpleEditor
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-10-03 13:22:50 +0000
committerhallgren <hallgren@chalmers.se>2012-10-03 13:22:50 +0000
commit3582ae6e085fcc2cfa2e0457c5674e22c5980fa5 (patch)
tree7ab1d82a06b0539670420fd32f70ac0811c2ccff /src/compiler/SimpleEditor
parenta1d2d11057b1ab727fdbec4430808d53d67128b1 (diff)
gfse: some refactoring
Diffstat (limited to 'src/compiler/SimpleEditor')
-rw-r--r--src/compiler/SimpleEditor/Convert.hs9
-rw-r--r--src/compiler/SimpleEditor/JSON.hs34
2 files changed, 16 insertions, 27 deletions
diff --git a/src/compiler/SimpleEditor/Convert.hs b/src/compiler/SimpleEditor/Convert.hs
index e2fc20358..e6cb98124 100644
--- a/src/compiler/SimpleEditor/Convert.hs
+++ b/src/compiler/SimpleEditor/Convert.hs
@@ -24,14 +24,13 @@ import SimpleEditor.JSON
parseModule (path,source) =
- prop path $
+ (path.=) $
case runP pModDef (BS.pack source) of
Left (Pn l c,msg) ->
- makeObj [prop "error" msg,
- prop "location" (show l++":"++show c)]
+ makeObj ["error".=msg, "location".= show l++":"++show c]
Right mod -> case convModule mod of
- Ok g -> makeObj [prop "converted" g]
- Bad msg -> makeObj [prop "parsed" msg]
+ Ok g -> makeObj ["converted".=g]
+ Bad msg -> makeObj ["parsed".=msg]
{-
convAbstractFile path =
diff --git a/src/compiler/SimpleEditor/JSON.hs b/src/compiler/SimpleEditor/JSON.hs
index 3c15e731b..8f607dc84 100644
--- a/src/compiler/SimpleEditor/JSON.hs
+++ b/src/compiler/SimpleEditor/JSON.hs
@@ -7,41 +7,31 @@ import SimpleEditor.Syntax
instance JSON Grammar where
showJSON (Grammar name extends abstract concretes) =
- makeObj [prop "basename" name,
- prop "extends" extends,
- prop "abstract" abstract,
- prop "concretes" concretes]
+ makeObj ["basename".=name, "extends".=extends,
+ "abstract".=abstract, "concretes".=concretes]
instance JSON Abstract where
showJSON (Abstract startcat cats funs) =
- makeObj [prop "startcat" startcat,
- prop "cats" cats,
- prop "funs" funs]
+ makeObj ["startcat".=startcat, "cats".=cats, "funs".=funs]
instance JSON Fun where showJSON (Fun name typ) = signature name typ
instance JSON Param where showJSON (Param name rhs) = definition name rhs
instance JSON Oper where showJSON (Oper name rhs) = definition name rhs
-signature name typ = makeObj [prop "name" name,prop "type" typ]
-definition name rhs = makeObj [prop "name" name,prop "rhs" rhs]
+signature name typ = makeObj ["name".=name,"type".=typ]
+definition name rhs = makeObj ["name".=name,"rhs".=rhs]
instance JSON Concrete where
showJSON (Concrete langcode opens params lincats opers lins) =
- makeObj [prop "langcode" langcode,
- prop "opens" opens,
- prop "params" params,
- prop "lincats" lincats,
- prop "opers" opers,
- prop "lins" lins]
+ makeObj ["langcode".=langcode, "opens".=opens,
+ "params".=params, "opers".=opers,
+ "lincats".=lincats, "lins".=lins]
instance JSON Lincat where
- showJSON (Lincat cat lintype) =
- makeObj [prop "cat" cat,prop "type" lintype]
+ showJSON (Lincat cat lintype) = makeObj ["cat".=cat, "type".=lintype]
instance JSON Lin where
- showJSON (Lin fun args lin) =
- makeObj [prop "fun" fun,
- prop "args" args,
- prop "lin" lin]
+ showJSON (Lin fun args lin) = makeObj ["fun".=fun, "args".=args, "lin".=lin]
-prop name v = (name,showJSON v)
+infix 1 .=
+name .= v = (name,showJSON v)