Skip to content

Instantly share code, notes, and snippets.

@PollRobots
Created February 1, 2013 07:38
Show Gist options
  • Save PollRobots/4689946 to your computer and use it in GitHub Desktop.
Save PollRobots/4689946 to your computer and use it in GitHub Desktop.
let rec codeGen (b:StringBuilder) i = function
| Terminal x -> ibprintf b i """matchTerminal "%s" input offset""" <| escape x
| TerminalOneOf x -> ibprintf b i """matchTerminalOneOf "%s" input offset""" <| escape x
| TerminalWildcard -> ibprintf b i """matchTerminalWildcard input offset"""
| TerminalUnicode x -> ibprintf b i """matchTerminalUnicode System.Globalization.UnicodeCategory.%s input offset""" <| string(x)
| Epsilon -> ibprintf b i """if offset = input.Length then (EmptyMatch, offset) else (Unmatched, offset)"""
| NonTerminal x -> ibprintf b i """matchRule%s input offset""" <| capitalIdentifier x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment