Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tokenizes an input stream to a list of Token
s
Arithmetic examples:
>>>
scan "1+2"
Right [Number 1.0,Operator "+",Number 2.0]
>>>
scan "(3/2+(1.5*2)) + 4.95"
Right [OpenParen,Number 3.0,Operator "/",Number 2.0,Operator "+",OpenParen,Number 1.5,Operator "*",Number 2.0,CloseParen,CloseParen,Operator "+",Number 4.95]
>>>
scan "9001*29.12"
Right [Number 9001.0,Operator "*",Number 29.12]
Examples with units:
>>>
scan "2km [m]"
Right [Number 2.0,Identifier "km",OpenBracket,Identifier "m",CloseBracket]
Examples with variables:
>>>
scan "a = 3, b = 2 -> a + b"
Right [Identifier "a",Equal,Number 3.0,Comma,Identifier "b",Equal,Number 2.0,Arrow,Identifier "a",Operator "+",Identifier "b"]
Documentation
Number Double | A number (integers are also represented as floats) |
Operator String | An operator |
OpenParen | Open parenthesis "(" |
CloseParen | Close parenthesis ")" |
OpenBracket | Open bracket "[" |
CloseBracket | Close bracket "]" |
Identifier String | Identifier (e.g. variable and function name) or unit |
Arrow | Arrow "->" |
Equal | Single equal sign "=" |
Comma | Comma "," |