Created
January 18, 2013 05:44
-
-
Save PollRobots/4562607 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| | ZeroOrMore x -> | |
| let rec parseList off = | |
| seq { | |
| match parse off x with | |
| | (Unmatched, _) -> () | |
| | (y, z) -> yield (y, z) | |
| yield! parseList z | |
| } | |
| let s = List.ofSeq <| parseList offset | |
| if List.isEmpty s then (EmptyMatch, offset) | |
| else (Production <| List.map fst s, snd <| List.maxBy snd s) | |
| | OneOrMore x -> | |
| let rec parseList off = | |
| seq { | |
| match parse off x with | |
| | (Unmatched, _) -> () | |
| | (y, z) -> yield (y, z) | |
| yield! parseList z | |
| } | |
| let s = List.ofSeq <| parseList offset | |
| if List.isEmpty s then (Unmatched, offset) | |
| else (Production <| List.map fst s, snd <| List.maxBy snd s) | |
| | Optional x -> | |
| match parse offset x with | |
| | (Unmatched, _) -> (EmptyMatch, offset) | |
| | y -> y | |
| | And x -> | |
| match parse offset x with | |
| | (Unmatched, _) -> (Unmatched, offset) | |
| | _ -> (EmptyMatch, offset) | |
| | Not x -> | |
| match parse offset x with | |
| | (Unmatched, _) -> (EmptyMatch, offset) | |
| | _ -> (Unmatched, offset) | |
| parse 0 grammar.[start] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment