Skip to content

Commit

Permalink
Fix regression: Change regex disamb to use follow restriction, disall…
Browse files Browse the repository at this point in the history
…owing newlines in regex patterns.
  • Loading branch information
Elmervc committed Jun 21, 2021
1 parent 8e2af06 commit 37e1a0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/org/webdsl/dsl/syntax/WebDSL-Regex.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ sorts ClassKeyword
[\&\]\-] -> BracketLiteral {reject}
[a-zA-Z0-9\!\#\%\'\,\:\;\<\=\>\@\_\`\~\&\]\-]
-> AtomLiteral
%% "/" -> AtomLiteral %%Dropped, causes ambs when having subsequent stats/exps with regexes
"/" -> AtomLiteral
[\}\)\|\[] -> AtomLiteral {reject}

[\\\|\$\*\+\?\.\{\}\(\)\&\]\-\[\^\!\#\%\'\,\:\;\<\=\>\@\_\`\~a-zA-Z0-9\t\n\r]*
-> AllChars
"/" -> AllChars
"\"" -> AllChars {cons("DoubleQuote") }

"\"" -> AllChars {cons("DoubleQuote") }

lexical restrictions
AtomLiteral -/- [\n]

sorts BracketCharacter AtomCharacter
context-free syntax
%%d "\{" -> BracketCharacter {cons("CurlyBraceOpen") }
Expand Down
4 changes: 4 additions & 0 deletions test/syntax/regex-0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function multiRegex(){
var first := /bla\n/.replaceAll("$1", x);
var second := /alb/.find(x);
}
11 changes: 11 additions & 0 deletions test/syntax/regex.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module regex

hiddens
context-free start-symbols
TestDef

context-free syntax
Function -> TestDef

imports
WebDSL

0 comments on commit 37e1a0a

Please sign in to comment.