diff --git a/hsrc/Syntax/Lexer.x b/hsrc/Syntax/Lexer.x index 640c0ea..d97838c 100644 --- a/hsrc/Syntax/Lexer.x +++ b/hsrc/Syntax/Lexer.x @@ -40,7 +40,9 @@ $escape_char = [abfnrtv'\"\\] -- Identifier $typestart $identrest* { emitS TokTypeIdent } + "prim%" $typestart $identrest* { emitS TokTypeIdent } $valstart $identrest* { emitS TokValIdent } + "prim%" $valstart $identrest* { emitS TokValIdent } $opident+ { emitS TokOpIdent } ":"+ { emitS TokOpIdent } @@ -60,6 +62,7 @@ $escape_char = [abfnrtv'\"\\] ";" { emitT Semi } "," { emitT Comma } "`" { emitT BTick } + [\\] { emitT LLambda } { diff --git a/hsrc/Syntax/Parser.y b/hsrc/Syntax/Parser.y index f76767c..4b7913f 100644 --- a/hsrc/Syntax/Parser.y +++ b/hsrc/Syntax/Parser.y @@ -38,7 +38,7 @@ import qualified Codec.Binary.UTF8.Generic as UTF8 '->' { Lexeme $$ (TokOpIdent "->") } '@' { Lexeme $$ (TokOpIdent "@") } '::' { Lexeme $$ (TokOpIdent "::") } - '\\' { Lexeme $$ (TokOpIdent "\\") } + '\\' { Lexeme $$ LLambda } '(' { Lexeme $$ LParen } ')' { Lexeme $$ RParen } '[' { Lexeme $$ LSquare } diff --git a/hsrc/Syntax/ParserCore.hs b/hsrc/Syntax/ParserCore.hs index 15060f1..1d60323 100644 --- a/hsrc/Syntax/ParserCore.hs +++ b/hsrc/Syntax/ParserCore.hs @@ -6,6 +6,7 @@ module Syntax.ParserCore where import Control.Applicative(Applicative) import qualified Data.ByteString as S import MonadLib +import System.IO -- -------------------------------------------------------------------------- -- Positions @@ -37,7 +38,7 @@ pprtPosition p = posFile p ++ ":" ++ show (posLine p) ++ ":" ++ show (posCol p) data Token = LParen | RParen | LSquare | RSquare | LBrace | RBrace - | Bar | Semi | Comma | BTick + | Bar | Semi | Comma | BTick | LLambda | TokTypeIdent String | TokValIdent String | TokOpIdent String @@ -74,7 +75,7 @@ data Error = Error ErrorType String Position deriving (Show) printError :: Error -> IO () -printError (Error etype str pos) = putStrLn errstr +printError (Error etype str pos) = hPutStrLn stderr errstr where errstr = pprtPosition pos ++ ":" ++ etypeStr ++ ": " ++ str etypeStr = case etype of