tokens in separate file
This commit is contained in:
parent
38ecabdda8
commit
2d7110b9c6
3 changed files with 48 additions and 29 deletions
|
@ -39,6 +39,8 @@
|
|||
"Quox.Syntax.Term.Subst",
|
||||
"Quox.Syntax.Universe",
|
||||
"Quox.Syntax.Var",
|
||||
|
||||
"Quox.Token",
|
||||
"Quox.Lexer",
|
||||
|
||||
"Quox.Context",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module Quox.Lexer
|
||||
|
||||
import Quox.Error
|
||||
import public Quox.Token
|
||||
|
||||
import Data.String
|
||||
import Data.String.Extra
|
||||
|
@ -19,35 +20,6 @@ record Error where
|
|||
line, col : Int
|
||||
char : Char
|
||||
|
||||
public export
|
||||
data Punc
|
||||
= LParen | RParen
|
||||
| LSquare | RSquare
|
||||
| LBrace | RBrace
|
||||
| Comma
|
||||
| Colon | DblColon
|
||||
| Arrow | DblArrow
|
||||
| Times | Triangle
|
||||
| Wild
|
||||
|
||||
%runElab derive "Punc" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
||| zero and one are separate because they are
|
||||
||| quantity & dimension constants
|
||||
public export
|
||||
data Number = Zero | One | Other Nat
|
||||
|
||||
%runElab derive "Number" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
public export
|
||||
data Token
|
||||
= P Punc
|
||||
| Name String | Symbol String
|
||||
| N Number
|
||||
|
||||
%runElab derive "Token" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
nameStart = pred $ \c => isAlpha c || c == '_'
|
||||
|
|
45
src/Quox/Token.idr
Normal file
45
src/Quox/Token.idr
Normal file
|
@ -0,0 +1,45 @@
|
|||
module Quox.Token
|
||||
|
||||
import Generics.Derive
|
||||
|
||||
%default total
|
||||
%language ElabReflection
|
||||
|
||||
|
||||
public export
|
||||
data Punc
|
||||
= LParen | RParen
|
||||
| LSquare | RSquare
|
||||
| LBrace | RBrace
|
||||
| Comma
|
||||
| Colon | DblColon
|
||||
| Arrow | DblArrow
|
||||
| Times | Triangle
|
||||
| Wild
|
||||
|
||||
%runElab derive "Punc" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
public export
|
||||
data Keyword
|
||||
= Fun | Let | In | Case | Of
|
||||
|
||||
%runElab derive "Keyword" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
||| zero and one are separate because they are
|
||||
||| quantity & dimension constants
|
||||
public export
|
||||
data Number = Zero | One | Other Nat
|
||||
|
||||
%runElab derive "Number" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
public export
|
||||
data Token
|
||||
= P Punc
|
||||
| Name String | Symbol String
|
||||
| N Number
|
||||
| K Keyword
|
||||
|
||||
%runElab derive "Token" [Generic, Meta, Eq, Ord, DecEq, Show]
|
Loading…
Reference in a new issue