This comparison shows the changes necessary to convert path / (Rev 23) TO / (Rev 24)
@@ -0,0 +1,75 @@
| {-# LANGUAGE FlexibleContexts #-} |
| {-# OPTIONS_GHC -Wall #-} |
| ------------------------------------------------------------------------------- |
| {- | |
| Module : Language.R.Parser |
| Description : Parser of the fork representation. |
| Copyright : (c) Paulo Silva |
| License : LGPL |
| Maintainer : paufil@di.uminho.pt |
| Stability : experimental |
| Portability : portable |
| -} |
| ------------------------------------------------------------------------------- |
| module Language.Fork.Parser ( |
| parser, |
| parseFork |
| ) where |
| import Control.GalcError |
| import Control.Monad.Error |
| import Language.R.SyntaxADT |
| import qualified Language.Type.Parser as T |
| import Text.ParserCombinators.Parsec |
| import Text.ParserCombinators.Parsec.Language |
| import qualified Text.ParserCombinators.Parsec.Token as P |
| import Text.ParserCombinators.Parsec.Expr |
| import Text.ParserCombinators.Parsec.Utils |
| ------------------------------------------------------------------------------- |
| parser :: MonadError GalcError m => String -> m S |
| parser = either2error (ParsingError . show) . parse (wrapper lexer parseFork) "" |
| parseFork :: Parser S |
| parseFork = buildExpressionParser table term |
| <?> "Fork expression" |
| term :: Parser S |
| term = |
| P.parens lexer parseFork <|> |
| parseIdentifierP lexer RefS <|> |
| parseVariableP lexer VarS <|> |
| parseKeywordP lexer "Id" IdS <|> |
| parseKeywordP lexer "Top" TopS <|> |
| parseKeywordP lexer "Bot" BotS <?> |
| "Fork simple expression" |
| table :: Table S |
| table = [ |
| [postfixP lexer "*" ConvS], |
| [prefixP lexer "~" NegS], |
| [binaryP lexer "/*\\" SplitS AssocLeft], |
| [binaryP lexer "/\\" MeetS AssocLeft, binaryP lexer "\\/" JoinS AssocLeft], |
| [binaryP lexer "." CompS AssocLeft] |
| ] |
| reservedNames' :: [String] |
| reservedNames' = ["Id", "Top", "Bot"] |
| reservedOpNames' :: [String] |
| reservedOpNames' = ["*", "~", "/*\\", "/\\", "\\/", "."] |
| lexer :: P.TokenParser st |
| lexer = P.makeTokenParser $ |
| emptyDef { P.reservedNames = reservedNames', |
| P.reservedOpNames = reservedOpNames', |
| P.identStart = lower } |
@@ -0,0 +1,75 @@
| {-# LANGUAGE FlexibleContexts #-} |
| {-# OPTIONS_GHC -Wall #-} |
| ------------------------------------------------------------------------------- |
| {- | |
| Module : Language.R.Parser |
| Description : Parser of the fork representation. |
| Copyright : (c) Paulo Silva |
| License : LGPL |
| Maintainer : paufil@di.uminho.pt |
| Stability : experimental |
| Portability : portable |
| -} |
| ------------------------------------------------------------------------------- |
| module Language.Fork.Parser ( |
| parser, |
| parseFork |
| ) where |
| import Control.GalcError |
| import Control.Monad.Error |
| import Language.R.SyntaxADT |
| import qualified Language.Type.Parser as T |
| import Text.ParserCombinators.Parsec |
| import Text.ParserCombinators.Parsec.Language |
| import qualified Text.ParserCombinators.Parsec.Token as P |
| import Text.ParserCombinators.Parsec.Expr |
| import Text.ParserCombinators.Parsec.Utils |
| ------------------------------------------------------------------------------- |
| parser :: MonadError GalcError m => String -> m S |
| parser = either2error (ParsingError . show) . parse (wrapper lexer parseFork) "" |
| parseFork :: Parser S |
| parseFork = buildExpressionParser table term |
| <?> "Fork expression" |
| term :: Parser S |
| term = |
| P.parens lexer parseFork <|> |
| parseIdentifierP lexer RefS <|> |
| parseVariableP lexer VarS <|> |
| parseKeywordP lexer "Id" IdS <|> |
| parseKeywordP lexer "Top" TopS <|> |
| parseKeywordP lexer "Bot" BotS <?> |
| "Fork simple expression" |
| table :: Table S |
| table = [ |
| [postfixP lexer "*" ConvS], |
| [prefixP lexer "~" NegS], |
| [binaryP lexer "/*\\" SplitS AssocLeft], |
| [binaryP lexer "/\\" MeetS AssocLeft, binaryP lexer "\\/" JoinS AssocLeft], |
| [binaryP lexer "." CompS AssocLeft] |
| ] |
| reservedNames' :: [String] |
| reservedNames' = ["Id", "Top", "Bot"] |
| reservedOpNames' :: [String] |
| reservedOpNames' = ["*", "~", "/*\\", "/\\", "\\/", "."] |
| lexer :: P.TokenParser st |
| lexer = P.makeTokenParser $ |
| emptyDef { P.reservedNames = reservedNames', |
| P.reservedOpNames = reservedOpNames', |
| P.identStart = lower } |