Skip to content

Commit

Permalink
Fixed recognizing strings with regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Sep 7, 2019
1 parent 9ca554e commit 0618a6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/com/zephir/Zephir.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
tokens = [
// regex
comment='regexp://.*'
comment_block='regexp:(/*([^*]+|[*]+[^/*])*[*]**/)'
comment_block='regexp:(/\*([^*]+|[*]+[^/*])*[*]*\*/)'
identifier='regexp:[_a-zA-Z][a-zA-Z0-9_]*'
integer='regexp:([\-]?[0-9]+)|([\-]?[0][x][0-9A-Fa-f]+)'
double='regexp:([\-]?[0-9]+[\.][0-9]+)'
double='regexp:([\-]?[0-9]+[.][0-9]+)'
schar="regexp:(['] ([\\][']|[\\].|[\001-\377]\[\\'])* ['])"
string='regexp:(["] ([\\]["]|[\\].|[\001-\377]\[\\"])* ["])'
cblock='regexp:%{([^}]+|[}]+[^%{])*}%'
Expand Down
8 changes: 4 additions & 4 deletions src/com/zephir/lexer/Zephir.flex
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ INTEGER=([\-]?[0-9]+)|([\-]?[0][x][0-9A-Fa-f]+)
DOUBLE=([\-]?[0-9]+[\.][0-9]+)
CBLOCK = ("%{"([^}]+|[}]+[^%{])*"}%")

// Steal this from Rust plugin
HEX_DIGIT = [a-fA-F0-9]
DOUBLE_QUOTE = \x22
SINGLE_QUOTE = \x27
COMMON_ESCAPE = ( [nrt0\n\r\\] | "x" {HEX_DIGIT} {2} | "u" {HEX_DIGIT} {4} | "U" {HEX_DIGIT} {8} )
SCHAR = {SINGLE_QUOTE} (( [^'\\] | "\\" ( {SINGLE_QUOTE} | {COMMON_ESCAPE}) ) | [^\x20-\x7E]{1,2}) {SINGLE_QUOTE}
STRING = {DOUBLE_QUOTE} ( [^\"\\] | "\\" ( {DOUBLE_QUOTE} | {SINGLE_QUOTE} | {COMMON_ESCAPE} | [dwWstrn.]) )* {DOUBLE_QUOTE} // dwWstrn - modifiers for slashed params, e.g \d
GENERIC_CHAR_TYPES = [acefntxdAGbBpPrRdDhHsSvVwWzZ]
COMMON_ESCAPE = ( [.0\n\r\\] | "x" {HEX_DIGIT} {2} | "u" {HEX_DIGIT} {4} | "U" {HEX_DIGIT} {8} )
SCHAR = {SINGLE_QUOTE} (( [^'\\] | "\\" ( {SINGLE_QUOTE} | {COMMON_ESCAPE} | {GENERIC_CHAR_TYPES}) ) | [^\x20-\x7E]{1,2}) {SINGLE_QUOTE}
STRING = {DOUBLE_QUOTE} ( [^\"\\] | "\\" ( {DOUBLE_QUOTE} | {SINGLE_QUOTE} | {COMMON_ESCAPE} | {GENERIC_CHAR_TYPES}) )* {DOUBLE_QUOTE}

%%
<YYINITIAL> {
Expand Down

0 comments on commit 0618a6a

Please sign in to comment.