BNFC-meta 0.3.0.1 → 0.3.0.2
raw patch · 9 files changed
+218/−218 lines, 9 filesdep ~arraydep ~template-haskellnew-uploader
Dependency ranges changed: array, template-haskell
Files
- BNFC-meta.cabal +7/−7
- examples/GHC6/jll/JavaletteLight.hs +0/−59
- examples/GHC6/jll/UseJll.hs +0/−46
- examples/GHC7/jll/JavaletteLight.hs +0/−60
- examples/GHC7/jll/UseJll.hs +0/−46
- examples/ghc6/jll/JavaletteLight.hs +59/−0
- examples/ghc6/jll/UseJll.hs +46/−0
- examples/ghc7/jll/JavaletteLight.hs +60/−0
- examples/ghc7/jll/UseJll.hs +46/−0
BNFC-meta.cabal view
@@ -1,5 +1,5 @@ Name: BNFC-meta-version: 0.3.0.1+version: 0.3.0.2 cabal-Version: >= 1.6 build-type: Simple license: GPL-2@@ -17,17 +17,17 @@ appropriate type. A few examples are included in the source tarball. extra-source-files:- examples/GHC7/jll/JavaletteLight.hs- examples/GHC7/jll/UseJll.hs- examples/GHC6/jll/JavaletteLight.hs- examples/GHC6/jll/UseJll.hs+ examples/ghc7/jll/JavaletteLight.hs+ examples/ghc7/jll/UseJll.hs+ examples/ghc6/jll/JavaletteLight.hs+ examples/ghc6/jll/UseJll.hs Bootstrap/Bootstrap.hs Library Build-Depends: base>=4.2&&<5- , array==0.3.0.*- , template-haskell >=2.4&&<2.7+ , array==0.4.*+ , template-haskell >=2.4&&<2.8 , haskell-src-meta >= 0.5 && < 1.0 , happy-meta >= 0.2.0.4 && < 0.3 , alex-meta >= 0.3.0.3 && < 0.4
− examples/GHC6/jll/JavaletteLight.hs
@@ -1,59 +0,0 @@-{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}--module JavaletteLight where--import Language.LBNF(lbnf, dumpCode, bnfc)-import Language.LBNF.Compiletime-import qualified Language.LBNF.Grammar----bnfc [$lbnf|---- This is a new pragma. The rest of the grammar is original JL.-antiquote "[" ":" ":]" ;---- Javalette Light: a simple subset of C, covering--- programs with a single zero-argument function.--- example: koe.jll--- ordinary rules--Fun. Prog ::= Typ Ident "(" ")" "{" [Stm] "}" ;--SDecl. Stm ::= Typ Ident ";" ;-SAss. Stm ::= Ident "=" Expr ";" ;-SIncr. Stm ::= Ident "++" ";" ;-SWhile. Stm ::= "while" "(" Expr ")" "{" [Stm] "}" ;--ELt. Expr0 ::= Expr1 "<" Expr1 ;-EPlus. Expr1 ::= Expr1 "+" Expr2 ;-ETimes. Expr2 ::= Expr2 "*" Expr3 ;-EVar. Expr3 ::= Ident ;-EInt. Expr3 ::= Integer ;-EDouble. Expr3 ::= Double ;--[]. [Stm] ::= ;-(:). [Stm] ::= Stm [Stm] ;---- coercions--_. Stm ::= Stm ";" ;--_. Expr ::= Expr0 ;-_. Expr0 ::= Expr1 ;-_. Expr1 ::= Expr2 ;-_. Expr2 ::= Expr3 ;-_. Expr3 ::= "(" Expr ")" ;--TInt. Typ ::= "int" ;-TDouble. Typ ::= "double" ;---- pragmas--comment "/*" "*/" ;-comment "//" ;--entrypoints Prog, Stm, Expr ;- |]--
− examples/GHC6/jll/UseJll.hs
@@ -1,46 +0,0 @@-{-# LANGUAGE QuasiQuotes #-}-import JavaletteLight-import Language.LBNF.Runtime -- overloaded pretty-printing function-import Prelude hiding (exp)--{- This Javalette Light program is parsed at compile time, -and replaced by it's abstract syntax representation.-The 'holes' in square brackets are anti-quoted Haskell -expression. --The QuasiQuoter prog is generated from the grammar in JavaletteLight.hs-(it corresponds to the category Prog).--}---prg x v e = [$prog|-int f() {- int a; - [:SWhile (EInt 10 :: Expr) [x]:]- int a;- int [:v:];- int tmp;- while (n < [Expr:e:]) {- n = n + 1;- tmp = a + b;- a = b;- b = tmp;- }-}-|] --st v = [$stm| [:v:] = 1; |]-pr = prg (st (Ident "n")) (Ident "n") [$expr|n|]-main = putStr $ printTree pr---eval vs = eval' where- eval' [$expr| [:a:] < [:b:] |] = if eval' a < eval' b then 1 else 0- eval' [$expr| [:a:] + [:b:] |] = eval' a + eval' b- eval' [$expr| [:a:] * [:b:] |] = eval' a * eval' b- eval' [$expr| [Integer: n:] |] = fromInteger n- eval' [$expr| [Double: n:] |] = n- eval' [$expr| [Ident: v:] |] = varval v- varval v = maybe (error $ "undefined variable" ++ printTree v) id $ flip lookup vs v--h = eval [(Ident "a",5)] [$expr|a+2+3*4|]
− examples/GHC7/jll/JavaletteLight.hs
@@ -1,60 +0,0 @@-{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}--module JavaletteLight where--import Language.LBNF(lbnf, dumpCode, bnfc)-import Language.LBNF.Compiletime-import qualified Language.LBNF.Grammar-----bnfc [lbnf|---- This is a new pragma. The rest of the grammar is original JL.-antiquote "[" ":" ":]" ;---- Javalette Light: a simple subset of C, covering--- programs with a single zero-argument function.--- example: koe.jll--- ordinary rules--Fun. Prog ::= Typ Ident "(" ")" "{" [Stm] "}" ;--SDecl. Stm ::= Typ Ident ";" ;-SAss. Stm ::= Ident "=" Expr ";" ;-SIncr. Stm ::= Ident "++" ";" ;-SWhile. Stm ::= "while" "(" Expr ")" "{" [Stm] "}" ;--ELt. Expr0 ::= Expr1 "<" Expr1 ;-EPlus. Expr1 ::= Expr1 "+" Expr2 ;-ETimes. Expr2 ::= Expr2 "*" Expr3 ;-EVar. Expr3 ::= Ident ;-EInt. Expr3 ::= Integer ;-EDouble. Expr3 ::= Double ;--[]. [Stm] ::= ;-(:). [Stm] ::= Stm [Stm] ;---- coercions--_. Stm ::= Stm ";" ;--_. Expr ::= Expr0 ;-_. Expr0 ::= Expr1 ;-_. Expr1 ::= Expr2 ;-_. Expr2 ::= Expr3 ;-_. Expr3 ::= "(" Expr ")" ;--TInt. Typ ::= "int" ;-TDouble. Typ ::= "double" ;---- pragmas--comment "/*" "*/" ;-comment "//" ;--entrypoints Prog, Stm, Expr ;- |]--
− examples/GHC7/jll/UseJll.hs
@@ -1,46 +0,0 @@-{-# LANGUAGE QuasiQuotes #-}-import JavaletteLight-import Language.LBNF.Runtime -- overloaded pretty-printing function-import Prelude hiding (exp)--{- This Javalette Light program is parsed at compile time, -and replaced by it's abstract syntax representation.-The 'holes' in square brackets are anti-quoted Haskell -expression. --The QuasiQuoter prog is generated from the grammar in JavaletteLight.hs-(it corresponds to the category Prog).--}---prg x v e = [prog|-int f() {- int a; - [:SWhile (EInt 10 :: Expr) [x]:]- int a;- int [:v:];- int tmp;- while (n < [Expr:e:]) {- n = n + 1;- tmp = a + b;- a = b;- b = tmp;- }-}-|] --st v = [stm| [:v:] = 1; |]-pr = prg (st (Ident "n")) (Ident "n") [expr|n|]-main = putStr $ printTree pr---eval vs = eval' where- varval v = maybe (error $ "undefined variable" ++ printTree v) id $ flip lookup vs v- eval' [expr| [:a:] < [:b:] |] = if eval' a < eval' b then 1 else 0- eval' [expr| [:a:] + [:b:] |] = eval' a + eval' b- eval' [expr| [:a:] * [:b:] |] = eval' a * eval' b- eval' [expr| [Integer: n:] |] = fromInteger n- eval' [expr| [Double: n:] |] = n- eval' [expr| [Ident: v:] |] = varval v--h = eval [(Ident "a",5)] [expr|a+2+3*4|]
+ examples/ghc6/jll/JavaletteLight.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}++module JavaletteLight where++import Language.LBNF(lbnf, dumpCode, bnfc)+import Language.LBNF.Compiletime+import qualified Language.LBNF.Grammar++++bnfc [$lbnf|++-- This is a new pragma. The rest of the grammar is original JL.+antiquote "[" ":" ":]" ;++-- Javalette Light: a simple subset of C, covering+-- programs with a single zero-argument function.+-- example: koe.jll+-- ordinary rules++Fun. Prog ::= Typ Ident "(" ")" "{" [Stm] "}" ;++SDecl. Stm ::= Typ Ident ";" ;+SAss. Stm ::= Ident "=" Expr ";" ;+SIncr. Stm ::= Ident "++" ";" ;+SWhile. Stm ::= "while" "(" Expr ")" "{" [Stm] "}" ;++ELt. Expr0 ::= Expr1 "<" Expr1 ;+EPlus. Expr1 ::= Expr1 "+" Expr2 ;+ETimes. Expr2 ::= Expr2 "*" Expr3 ;+EVar. Expr3 ::= Ident ;+EInt. Expr3 ::= Integer ;+EDouble. Expr3 ::= Double ;++[]. [Stm] ::= ;+(:). [Stm] ::= Stm [Stm] ;++-- coercions++_. Stm ::= Stm ";" ;++_. Expr ::= Expr0 ;+_. Expr0 ::= Expr1 ;+_. Expr1 ::= Expr2 ;+_. Expr2 ::= Expr3 ;+_. Expr3 ::= "(" Expr ")" ;++TInt. Typ ::= "int" ;+TDouble. Typ ::= "double" ;++-- pragmas++comment "/*" "*/" ;+comment "//" ;++entrypoints Prog, Stm, Expr ;+ |]++
+ examples/ghc6/jll/UseJll.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE QuasiQuotes #-}+import JavaletteLight+import Language.LBNF.Runtime -- overloaded pretty-printing function+import Prelude hiding (exp)++{- This Javalette Light program is parsed at compile time, +and replaced by it's abstract syntax representation.+The 'holes' in square brackets are anti-quoted Haskell +expression. ++The QuasiQuoter prog is generated from the grammar in JavaletteLight.hs+(it corresponds to the category Prog).+-}+++prg x v e = [$prog|+int f() {+ int a; + [:SWhile (EInt 10 :: Expr) [x]:]+ int a;+ int [:v:];+ int tmp;+ while (n < [Expr:e:]) {+ n = n + 1;+ tmp = a + b;+ a = b;+ b = tmp;+ }+}+|] ++st v = [$stm| [:v:] = 1; |]+pr = prg (st (Ident "n")) (Ident "n") [$expr|n|]+main = putStr $ printTree pr+++eval vs = eval' where+ eval' [$expr| [:a:] < [:b:] |] = if eval' a < eval' b then 1 else 0+ eval' [$expr| [:a:] + [:b:] |] = eval' a + eval' b+ eval' [$expr| [:a:] * [:b:] |] = eval' a * eval' b+ eval' [$expr| [Integer: n:] |] = fromInteger n+ eval' [$expr| [Double: n:] |] = n+ eval' [$expr| [Ident: v:] |] = varval v+ varval v = maybe (error $ "undefined variable" ++ printTree v) id $ flip lookup vs v++h = eval [(Ident "a",5)] [$expr|a+2+3*4|]
+ examples/ghc7/jll/JavaletteLight.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE QuasiQuotes, TemplateHaskell #-}++module JavaletteLight where++import Language.LBNF(lbnf, dumpCode, bnfc)+import Language.LBNF.Compiletime+import qualified Language.LBNF.Grammar+++++bnfc [lbnf|++-- This is a new pragma. The rest of the grammar is original JL.+antiquote "[" ":" ":]" ;++-- Javalette Light: a simple subset of C, covering+-- programs with a single zero-argument function.+-- example: koe.jll+-- ordinary rules++Fun. Prog ::= Typ Ident "(" ")" "{" [Stm] "}" ;++SDecl. Stm ::= Typ Ident ";" ;+SAss. Stm ::= Ident "=" Expr ";" ;+SIncr. Stm ::= Ident "++" ";" ;+SWhile. Stm ::= "while" "(" Expr ")" "{" [Stm] "}" ;++ELt. Expr0 ::= Expr1 "<" Expr1 ;+EPlus. Expr1 ::= Expr1 "+" Expr2 ;+ETimes. Expr2 ::= Expr2 "*" Expr3 ;+EVar. Expr3 ::= Ident ;+EInt. Expr3 ::= Integer ;+EDouble. Expr3 ::= Double ;++[]. [Stm] ::= ;+(:). [Stm] ::= Stm [Stm] ;++-- coercions++_. Stm ::= Stm ";" ;++_. Expr ::= Expr0 ;+_. Expr0 ::= Expr1 ;+_. Expr1 ::= Expr2 ;+_. Expr2 ::= Expr3 ;+_. Expr3 ::= "(" Expr ")" ;++TInt. Typ ::= "int" ;+TDouble. Typ ::= "double" ;++-- pragmas++comment "/*" "*/" ;+comment "//" ;++entrypoints Prog, Stm, Expr ;+ |]++
+ examples/ghc7/jll/UseJll.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE QuasiQuotes #-}+import JavaletteLight+import Language.LBNF.Runtime -- overloaded pretty-printing function+import Prelude hiding (exp)++{- This Javalette Light program is parsed at compile time, +and replaced by it's abstract syntax representation.+The 'holes' in square brackets are anti-quoted Haskell +expression. ++The QuasiQuoter prog is generated from the grammar in JavaletteLight.hs+(it corresponds to the category Prog).+-}+++prg x v e = [prog|+int f() {+ int a; + [:SWhile (EInt 10 :: Expr) [x]:]+ int a;+ int [:v:];+ int tmp;+ while (n < [Expr:e:]) {+ n = n + 1;+ tmp = a + b;+ a = b;+ b = tmp;+ }+}+|] ++st v = [stm| [:v:] = 1; |]+pr = prg (st (Ident "n")) (Ident "n") [expr|n|]+main = putStr $ printTree pr+++eval vs = eval' where+ varval v = maybe (error $ "undefined variable" ++ printTree v) id $ flip lookup vs v+ eval' [expr| [:a:] < [:b:] |] = if eval' a < eval' b then 1 else 0+ eval' [expr| [:a:] + [:b:] |] = eval' a + eval' b+ eval' [expr| [:a:] * [:b:] |] = eval' a * eval' b+ eval' [expr| [Integer: n:] |] = fromInteger n+ eval' [expr| [Double: n:] |] = n+ eval' [expr| [Ident: v:] |] = varval v++h = eval [(Ident "a",5)] [expr|a+2+3*4|]