From 988f5ca7d5e1a1f9e1b67d61d74de055c1f20f15 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 10 Feb 2018 11:23:56 -0500 Subject: [PATCH] Adding sticky and unicode flags Closes #33 --- spec/parser/javascript/root_spec.js | 8 ++++++++ src/js/parser/javascript/grammar.peg | 2 +- src/js/parser/javascript/root.js | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/parser/javascript/root_spec.js b/spec/parser/javascript/root_spec.js index a7dd1ec..7ec1878 100644 --- a/spec/parser/javascript/root_spec.js +++ b/spec/parser/javascript/root_spec.js @@ -25,6 +25,14 @@ describe('parser/javascript/root.js', function() { flags: ['Multiline'], regexp: jasmine.objectContaining({ textValue: 'test' }) }, + '/test/y': { + flags: ['Sticky'], + regexp: jasmine.objectContaining({ textValue: 'test' }) + }, + '/test/u': { + flags: ['Unicode'], + regexp: jasmine.objectContaining({ textValue: 'test' }) + }, '/test/mgi': { flags: ['Global', 'Ignore Case', 'Multiline'], regexp: jasmine.objectContaining({ textValue: 'test' }) diff --git a/src/js/parser/javascript/grammar.peg b/src/js/parser/javascript/grammar.peg index 37ef9d5..cdc84c7 100644 --- a/src/js/parser/javascript/grammar.peg +++ b/src/js/parser/javascript/grammar.peg @@ -1,5 +1,5 @@ grammar JavascriptRegexp - root <- ( ( "/" regexp "/" flags:[igm]* ) / regexp flags:""? ) + root <- ( ( "/" regexp "/" flags:[yigmu]* ) / regexp flags:""? ) regexp <- match:match alternates:( "|" match )* match <- (!repeat) parts:match_fragment* anchor <- ( "^" / "$" ) diff --git a/src/js/parser/javascript/root.js b/src/js/parser/javascript/root.js index cc6c89c..1756100 100644 --- a/src/js/parser/javascript/root.js +++ b/src/js/parser/javascript/root.js @@ -9,7 +9,9 @@ export default { flagLabels: { i: 'Ignore Case', g: 'Global', - m: 'Multiline' + m: 'Multiline', + y: 'Sticky', + u: 'Unicode' }, // Renders the root into the currently set container.