import Data.Either
import Data.Maybe
import Data.Map
+import Data.Func
import StdString
+import StdTuple
import StdBool
import StdList
import StdChar
('<', LesserToken), ('>', BiggerToken), ('!', ExclamationToken)]
EscapeMap :: Map Char Char
-EscapeMap = fromList [
- ('a', toChar 7), ('b', '\b'), ('f', '\f'), ('n', '\n'), ('r', '\r'),
- ('t', '\t'), ('v', '\v')]
+EscapeMap = fromList [('a', toChar 7), ('b', '\b'), ('f', '\f'), ('n', '\n'),
+ ('r', '\r'), ('t', '\t'), ('v', '\v')]
lexer :: [Char] -> LexerOutput
lexer [] = Right []
lex :: [Char] -> (Either String Token, [Char])
lex [] = (Right EndOfFileToken, [])
-lex ['/':'/':x:rest] = if (x == '\n') (lex rest) (lex ['/':'/':rest])
-lex ['/':'*':x1:x2:rest] = if (x1 == '*' && x2 == '/')
- (lex rest) (lex ['/':'*':rest])
-lex ['v':'a':'r':rest] = (Right VarToken, rest)
-lex ['V':'o':'i':'d':rest] = (Right VoidToken, rest)
-lex ['r':'e':'t':'u':'r':'n':rest] = (Right ReturnToken, rest)
-lex ['i':'f':rest] = (Right IfToken, rest)
-lex ['e':'l':'s':'e':rest] = (Right ElseToken, rest)
-lex ['w':'h':'i':'l':'e':rest] = (Right WhileToken, rest)
-lex ['T':'r':'u':'e':rest] = (Right TrueToken, rest)
-lex ['F':'a':'l':'s':'e':rest] = (Right FalseToken, rest)
-lex ['I':'n':'t':rest] = (Right IntTypeToken, rest)
-lex ['C':'h':'a':'r':rest] = (Right CharTypeToken, rest)
-lex ['B':'o':'o':'l':rest] = (Right BoolTypeToken, rest)
-lex [':':':':rest] = (Right DoubleColonToken, rest)
-lex ['!':'=':rest] = (Right NotEqualToken, rest)
-lex ['<':'=':rest] = (Right LesserEqToken, rest)
-lex ['>':'=':rest] = (Right GreaterEqToken, rest)
-lex ['=':'=':rest] = (Right EqualsToken, rest)
-lex ['&':'&':rest] = (Right AmpersandsToken, rest)
-lex ['|':'|':rest] = (Right PipesToken, rest)
-lex ['-':'>':rest] = (Right ArrowToken, rest)
-lex ['\'':x:'\'':rest] = (Right (CharToken x), rest)
-lex ['\'':'\\':x:'\'':rest] = case get x EscapeMap of
- Just t = (Right (CharToken t), rest)
+lex ['/':'/':xs] = lex $ dropWhile ((<>) '\n') xs
+lex ['/':'*':xs] = lex $ tl $ map snd $ dropWhile ((<>) ('*', '/')) $ zip2 [zero:xs] xs
+lex ['v':'a':'r':xs] = (Right VarToken, xs)
+lex ['V':'o':'i':'d':xs] = (Right VoidToken, xs)
+lex ['r':'e':'t':'u':'r':'n':xs] = (Right ReturnToken, xs)
+lex ['i':'f':xs] = (Right IfToken, xs)
+lex ['e':'l':'s':'e':xs] = (Right ElseToken, xs)
+lex ['w':'h':'i':'l':'e':xs] = (Right WhileToken, xs)
+lex ['T':'r':'u':'e':xs] = (Right TrueToken, xs)
+lex ['F':'a':'l':'s':'e':xs] = (Right FalseToken, xs)
+lex ['I':'n':'t':xs] = (Right IntTypeToken, xs)
+lex ['C':'h':'a':'r':xs] = (Right CharTypeToken, xs)
+lex ['B':'o':'o':'l':xs] = (Right BoolTypeToken, xs)
+lex [':':':':xs] = (Right DoubleColonToken, xs)
+lex ['!':'=':xs] = (Right NotEqualToken, xs)
+lex ['<':'=':xs] = (Right LesserEqToken, xs)
+lex ['>':'=':xs] = (Right GreaterEqToken, xs)
+lex ['=':'=':xs] = (Right EqualsToken, xs)
+lex ['&':'&':xs] = (Right AmpersandsToken, xs)
+lex ['|':'|':xs] = (Right PipesToken, xs)
+lex ['-':'>':xs] = (Right ArrowToken, xs)
+lex ['\'':x:'\'':xs] = (Right (CharToken x), xs)
+lex ['\'':'\\':x:'\'':xs] = case get x EscapeMap of
+ Just t = (Right (CharToken t), xs)
_ = (Left ("Unknown escape: \\" +++ toString x), [])
-lex [x:rest]
+lex [x:xs]
# t = get x SingleCharTokens
-| isJust t = (Right (fromJust t), rest)
-| isSpace x = lex rest
-| isDigit x = let (is, rest`) = span isDigit rest in
- (Right (NumberToken [x:is]), rest`)
-| isAlpha x = let (is, rest`) = span (\c.isAlphanum c || c == '_') rest in
- (Right (IdentToken [x:is]), rest`)
+| isJust t = (Right (fromJust t), xs)
+| isSpace x = lex xs
+| isDigit x = let (is, xs`) = span isDigit xs in
+ (Right (NumberToken [x:is]), xs`)
+| isAlpha x = let (is, xs`) = span (\c.isAlphanum c || c == '_') xs in
+ (Right (IdentToken [x:is]), xs`)
| otherwise = (Left ("Unexpected character: " +++ toString x), [])
Link
LinkMethod: Static
GenerateRelocations: False
- GenerateSymbolTable: False
GenerateLinkMap: False
LinkResources: False
ResourceSource:
Fusion: False
Module
Name: Control.Applicative
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Control.Monad
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Either
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Foldable
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Func
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Functor
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.List
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Map
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Maybe
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Monoid
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Set
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Traversable
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Data.Void
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: System.IO
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Text
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Text.JSON
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
Fusion: False
Module
Name: Text.PPrint
- Dir: {Application}/lib/iTasks-SDK/Dependencies/clean-platform/src/libraries/OS-Independent
+ Dir: {Application}/lib/iTasks-SDK/Dependencies/Platform/OS-Independent
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False