Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created June 9, 2009 22:16
Show Gist options
  • Save carllerche/126844 to your computer and use it in GitHub Desktop.
Save carllerche/126844 to your computer and use it in GitHub Desktop.
class Splinter::RegexpParser
rule
\[(\^)? { state = :CCLASS ; [:LSQUARE, ss[1] && :negate] }
\( { [:LPAREN, text] }
\) { [:RPAREN, text] }
\| { [:PIPE, text] }
\+ { [:PLUS, text] }
\* { [:STAR, text] }
\? { [:QMARK, text] }
\. { [:DOT, text] }
\\?(.) { [:CHAR, ss[1]] }
:CCLASS \] { state = nil ; [:RSQUARE, text] }
:CCLASS (?:\\.|[^-])-(\\.|[^-\]]) { [:RANGE, text] }
:CCLASS (?:\\(.)|(.)) { [:CHAR, ss[1] || ss[2]] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment