Skip to content

Commit

Permalink
Merge pull request #117 from codalogic/regex-format-alignment
Browse files Browse the repository at this point in the history
Aligning regex grammar to q_string grammar
Only the Travis CI mac builds are problematic, but that is a service issue with Travis CI.
  • Loading branch information
anewton1998 committed Jan 19, 2018
2 parents 5190aff + 556d919 commit 8ea3b6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions abnf/jcr-abnf.txt
Expand Up @@ -200,10 +200,10 @@ quotation-mark = %x22 ; " quotation mark U+0022
char = unescaped /
escape (
quotation-mark /
escape-codes )
escape-code )
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF ; Not " or \
escape = %x5C ; \
escape-codes =
escape-code =
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
Expand All @@ -218,16 +218,17 @@ single-quote-mark = %x27 ; ' single quotation mark U+0027
sq-char = sq-unescaped /
escape (
single-quote-mark /
escape-codes )
escape-code )
sq-unescaped = %x20-26 / %x28-5B / %x5D-10FFFF ; Not ' or \

regex = "/" *( escape "/" / not-slash ) "/"
regex = "/" *( escape re-escape-code / not-slash ) "/"
[ regex-modifiers ]
re-escape-code = %x20-7F ; Specific codes listed elsewhere
not-slash = HTAB / CR / LF / %x20-2E / %x30-10FFFF
; Any char except "/"
regex-modifiers = *( "i" / "s" / "x" )

backtick-regex = "`" *( escape "`" / not-backtick ) "`"
backtick-regex = "`" *( escape re-escape-code / not-backtick ) "`"
not-backtick = HTAB / CR / LF / %x20-5F / %x61-10FFFF
; Any char except "`"
uri-scheme = 1*ALPHA
Expand Down
11 changes: 6 additions & 5 deletions lib/jcr/parser.rb
Expand Up @@ -429,10 +429,10 @@ class Parser < Parslet::Parser
#! char = unescaped /
#! escape (
#! quotation-mark /
#! escape_codes )
#! escape_code )
#! unescaped = %x20-21 / %x23-5B / %x5D-10FFFF ; Not " or \
#! escape = %x5C ; \
#! escape_codes =
#! escape_code =
#! %x5C / ; \ reverse solidus U+005C
#! %x2F / ; / solidus U+002F
#! %x62 / ; b backspace U+0008
Expand All @@ -454,21 +454,22 @@ class Parser < Parslet::Parser
#! sq_char = sq_unescaped /
#! escape (
#! single-quote-mark /
#! escape_codes )
#! escape_code )
#! sq_unescaped = %x20-26 / %x28-5B / %x5D-10FFFF ; Not ' or \
#!

rule(:regex) { str('/') >> (str('\\/') | match('[^/]+')).repeat.as(:regex) >> str('/') >> regex_modifiers.maybe }
#! regex = "/" *( escape "/" / not-slash ) "/"
#! regex = "/" *( escape re_escape_code / not-slash ) "/"
#! [ regex_modifiers ]
#! re_escape_code = %x20-7F ; Specific codes listed elsewhere
#! not-slash = HTAB / CR / LF / %x20-2E / %x30-10FFFF
#! ; Any char except "/"
rule(:regex_modifiers) { match('[isx]').repeat.as(:regex_modifiers) }
#! regex_modifiers = *( "i" / "s" / "x" )
#!

rule(:backtick_regex) { str('`') >> (str('\\`') | match('[^`]+')).repeat.as(:regex) >> str('`') }
#! backtick_regex = "`" *( escape "`" / not-backtick ) "`"
#! backtick_regex = "`" *( escape re_escape_code / not-backtick ) "`"
#! not-backtick = HTAB / CR / LF / %x20-5F / %x61-10FFFF
#! ; Any char except "`"

Expand Down

0 comments on commit 8ea3b6a

Please sign in to comment.