slight parser optimization
This commit is contained in:
parent
7c24f93efc
commit
9275d39107
|
@ -222,16 +222,23 @@ lexPi str =
|
|||
{- Basic idea, parsing has a list of the identifiers to convert to -}
|
||||
{- de bruijn indecies, and a Nat to keep track of context size -}
|
||||
mutual
|
||||
-- has pi, sigma, and arrows, strongest binding
|
||||
expr : List String -> (n : Nat) -> Vect n String -> Grammar () PiToken True (Term n)
|
||||
expr defs n env = tpi defs n env
|
||||
<|> tsigma defs n env
|
||||
<|> (do
|
||||
e <- expr1 defs n env
|
||||
tarr defs n env e <|> tapp defs n env e <|> pure e)
|
||||
|
||||
tarr defs n env e <|> pure e)
|
||||
|
||||
-- handles application of expr2s (and terms)
|
||||
expr1 : List String -> (n : Nat) -> Vect n String -> Grammar () PiToken True (Term n)
|
||||
expr1 defs n env = ttopind defs n env
|
||||
expr1 defs n env = do
|
||||
e <- expr2 defs n env
|
||||
tapp defs n env e <|> pure e
|
||||
|
||||
-- anything which has an application in it (and induction principle) or a term
|
||||
expr2 : List String -> (n : Nat) -> Vect n String -> Grammar () PiToken True (Term n)
|
||||
expr2 defs n env = ttopind defs n env
|
||||
<|> tbotind defs n env
|
||||
<|> tsuc defs n env
|
||||
<|> tnatind defs n env
|
||||
|
@ -239,10 +246,9 @@ mutual
|
|||
<|> tid defs n env
|
||||
<|> trefl defs n env
|
||||
<|> tj defs n env
|
||||
<|> (do
|
||||
t <- term defs n env
|
||||
tapp defs n env t <|> pure t)
|
||||
<|> term defs n env
|
||||
|
||||
-- terms, no application
|
||||
term : List String -> (n : Nat) -> Vect n String -> Grammar () PiToken True (Term n)
|
||||
term defs n env = ttype
|
||||
<|> ttop
|
||||
|
|
Loading…
Reference in New Issue
Block a user