perf(library/init/lean/parser/token): move number' out of longest_match call

This commit is contained in:
Sebastian Ullrich 2018-09-13 17:54:40 -07:00
parent 123adc1ae2
commit 468ac814a7
2 changed files with 2 additions and 2 deletions

View file

@ -221,7 +221,7 @@ def not_followed_by (p : parsec' α) (msg : string := "input") : parsec' unit :=
def dbg (label : string) (p : parsec_t μ m α) : parsec_t μ m α :=
λ it, do
r ← p it,
pure $ trace ("DBG " ++ label ++ ": '" ++ (it.extract (it.nextn 40)).get_or_else "" ++ "'") $ match r : _ → result μ α with
pure $ trace ("DBG " ++ label ++ ": \"" ++ (it.extract (it.nextn 40)).get_or_else "" ++ "\"") $ match r : _ → result μ α with
| ok a it' := trace ("consumed ok : '" ++ (it.extract it').get_or_else "" ++ "'") $ @ok μ α a it'
| ok_eps a it' ex := trace ("empty ok : '" ++ (it.extract it').get_or_else "" ++ "'") $ @ok_eps μ α a it' ex
| error msg tt := trace ("consumed error : '" ++ (it.extract msg.it).get_or_else "" ++ "'\n" ++ to_string msg) $ @error μ α msg tt

View file

@ -108,7 +108,7 @@ def token : basic_parser_m syntax :=
do (r, i) ← with_source_info $ do {
-- NOTE the order: if a token is both a symbol and a valid identifier (i.e. a keyword),
-- we want it to be recognized as a symbol
f::_ ← longest_match [symbol', ident', number'] | failure,
f::_ ← longest_match [symbol', ident'] <|> list.ret <$> number' | failure,
pure f
},
pure (r i)