import qualified Data.Set as Set
import qualified Data.Text as Text
-import Symantic.Univariant.Trans
+import qualified Symantic.Class as Prod
import qualified Symantic.Parser as P
-import qualified Symantic.Parser.Haskell as H
type Parser a = P.Parser Text.Text a
charLit = P.between (P.char '\'') (symbol '\'') charChar
charChar :: repr ()
charChar = P.void (P.satisfy
- (trans (H.ValueCode nandStringLetter [||nandStringLetter||]))) P.<|> esc
+ (P.production nandStringLetter [||nandStringLetter||])) P.<|> esc
esc :: repr ()
esc = P.char '\\' P.*> P.void (P.oneOf "0tnvfr")
expr :: repr ()
identifier :: repr ()
identifier = P.try (identStart P.*> P.skipMany identLetter) P.*> whitespace
identStart = P.satisfy
- (trans (H.ValueCode nandIdentStart [||nandIdentStart||]))
+ (P.production nandIdentStart [||nandIdentStart||])
exprlist = commaSep expr
exprlist1 = commaSep1 expr
block = braces (P.skipMany statement)
statement =
ifstmt P.<|> whilestmt P.<|> P.try varstmt P.<|> expr P.<* semi
- -- P.pure H.unit
+ -- P.pure Prod.unit
ifstmt = keyword "if" -- P.*> expr P.*> block P.*> P.optional (keyword "else" P.*> block)
whilestmt = keyword "while" P.*> expr P.*> block
varstmt = P.optional (keyword "var") P.*> varlist1 P.*> symbol '=' P.*> exprlist1 P.<* semi
keyword :: String -> repr ()
- keyword k = P.string k P.*> P.pure H.unit
+ keyword k = P.string k P.*> P.pure Prod.unit
{-
keyword s = P.try (P.string s P.*> notIdentLetter) P.*> whitespace
notIdentLetter = P.negLook identLetter
-}
identLetter = P.satisfy
- (trans (H.ValueCode nandIdentLetter [||nandIdentLetter||]))
+ (P.production nandIdentLetter [||nandIdentLetter||])
-- hexadecimal = P.oneOf "xX" P.*> number (P.oneOf (['a'..'f'] <> ['A'..'F'] <> ['0'..'9']))
-- octal = P.oneOf "oO" P.*> number (P.oneOf ['0'..'7'])
commaSep1 p = p P.*> P.skipMany (comma P.*> p)
space :: repr ()
- space = P.void (P.satisfy
- (trans (H.ValueCode isSpace [||isSpace||])))
+ space = P.void (P.satisfy (P.production isSpace [||isSpace||]))
whitespace :: repr ()
whitespace = spaces
{-
whitespace = P.skipMany (spaces P.<|> oneLineComment)
oneLineComment :: repr ()
oneLineComment = P.void (P.string "//" P.*> P.skipMany (P.satisfy
- (trans (H.ValueCode (/= '\n') [||(/= '\n')||]))))
+ (P.production (/= '\n') [||(/= '\n')||])))
-}
spaces :: repr ()
spaces = P.skipSome space