Skip to content

Commit

Permalink
Keep partially dead states in the lexer
Browse files Browse the repository at this point in the history
They are important.
  • Loading branch information
baioc committed Aug 12, 2021
1 parent 5bbeb5a commit 4e6b2ee
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Shared/Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,20 @@ module Lexer =
union
|> Dfa.filter (fun (q, a) q' -> q' <> set [ dead ])
|> Dfa.map
(fun s ->
s
|> Seq.filter (fun state -> state <> dead)
|> Seq.map
(fun (prefix, state) ->
if Set.contains s union.Accepting then
(fun state ->
Set.map
(fun (prefix, discriminant) ->
if Set.contains state union.Accepting then
match Map.tryFind prefix spec with
| Some (TokenClass (r, priority)) ->
AcceptToken (prefix, state, priority)
AcceptToken (prefix, discriminant, priority)
| Some (Separator r) ->
AcceptSeparator (prefix, state)
AcceptSeparator (prefix, discriminant)
| notAccepting ->
Intermediary (prefix, state)
Intermediary (prefix, discriminant)
else
Intermediary (prefix, state))
|> Set.ofSeq)
Intermediary (prefix, discriminant))
state)

{ Automaton = automaton; Initial = automaton.Current
String = ""; Start = 0u; Position = 0u }
Expand Down

0 comments on commit 4e6b2ee

Please sign in to comment.