quox/lib/on-hold/Quox/Token.idr

50 lines
887 B
Idris
Raw Normal View History

2022-05-04 09:30:08 -04:00
module Quox.Token
import Generics.Derive
2022-05-06 15:58:32 -04:00
import Text.Lexer
2022-05-04 09:30:08 -04:00
%default total
%language ElabReflection
public export
data Punc
= LParen | RParen
| LSquare | RSquare
| LBrace | RBrace
| Comma
| Colon | DblColon
2022-05-06 15:35:04 -04:00
| Dot
2022-05-04 09:30:08 -04:00
| Arrow | DblArrow
| Times | Triangle
| Wild
%runElab derive "Punc" [Generic, Meta, Eq, Ord, DecEq, Show]
public export
data Keyword
2022-05-07 15:57:10 -04:00
= Lam | Let | In | Case | Of | Omega
2022-05-09 12:31:30 -04:00
| Pi | Sigma | W
2022-05-04 09:30:08 -04:00
%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
| K Keyword
2022-05-09 12:31:30 -04:00
| Name String | Symbol String
| N Number | TYPE Nat
2022-05-04 09:30:08 -04:00
%runElab derive "Token" [Generic, Meta, Eq, Ord, DecEq, Show]
2022-05-06 15:58:32 -04:00
public export
BToken : Type
BToken = WithBounds Token