repositories
/
cc1516.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Work in progress code gen
[cc1516.git]
/
lex.icl
diff --git
a/lex.icl
b/lex.icl
index
21a29e9
..
aa34987
100644
(file)
--- a/
lex.icl
+++ b/
lex.icl
@@
-1,14
+1,16
@@
implementation module lex
import Control.Monad, Control.Applicative
implementation module lex
import Control.Monad, Control.Applicative
-import Data.Either, Data.Func
+import Data.Either, Data.Func
, Data.Void
from StdFunc import o
import StdBool
import StdList
import StdChar
import StdString
from StdFunc import o
import StdBool
import StdList
import StdChar
import StdString
+import StdTuple
import yard
import yard
+import AST
:: LexItem
= LexToken Int TokenValue
:: LexItem
= LexToken Int TokenValue
@@
-18,9
+20,7
@@
import yard
| LexItemError String
lexer :: [Char] -> LexerOutput
| LexItemError String
lexer :: [Char] -> LexerOutput
-lexer r = case runParser (lexProgram 1 1) r of
- (Right p, _) = Right p
- (Left e, _) = Left e
+lexer r = fst $ runParser (lexProgram 1 1) r
lexProgram :: Int Int -> Parser Char [Token]
lexProgram line column = lexToken >>= \t->case t of
lexProgram :: Int Int -> Parser Char [Token]
lexProgram line column = lexToken >>= \t->case t of
@@
-30,7
+30,7
@@
lexProgram line column = lexToken >>= \t->case t of
(LexItemError e) = fail <?>
PositionalError line column ("LexerError: " +++ e)
(LexToken c t) = lexProgram line (column+c)
(LexItemError e) = fail <?>
PositionalError line column ("LexerError: " +++ e)
(LexToken c t) = lexProgram line (column+c)
- >>= \rest->pure [
{line=line, column=column, token=t}
:rest]
+ >>= \rest->pure [
({line=line,col=column}, t)
:rest]
lexToken :: Parser Char LexItem
lexToken =
lexToken :: Parser Char LexItem
lexToken =