Created
January 19, 2012 12:13
-
-
Save manveru/1639756 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
require 'parslet' | |
class PdfParser < Parslet::Parser | |
rule(:spaces) { match('\s').repeat(1) } | |
rule(:spaces?) { spaces.maybe } | |
rule(:integer) { match('[0-9]').repeat } | |
rule(:separator) { str(":") } | |
rule(:slash) { str("/") } | |
rule(:rciwn_number) { integer >> slash >> integer } | |
rule(:rciwn) { str("Number RCiWN") >> separator >> spaces? >> rciwn_number.as(:number) } | |
root(:rciwn) | |
end | |
parser = PdfParser.new | |
p parser.parse("Number RCiWN: 123/32") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment