Skip to content

Commit

Permalink
fixing escaped special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewCodeDev committed Sep 6, 2024
1 parent 68e0c33 commit f365786
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions fluent.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2767,17 +2767,20 @@ fn ParseRegexTreeDepth(comptime sq: []const RegexSymbol) type {
if (s.escaped and isCharFunction(s.char)) {
break :outer RegexUnit(BindCharFunction(s.char, s.negated), q);
} else {
switch (s.char) {
'.' => break :outer RegexUnit(anyRegex, q),
'^' => {
if (q != null) @compileError("Symbol '^' cannot have a quantifier.");
break :outer RegexUnit(startsWithRegex, null);
},
'$' => {
if (q != null) @compileError("Symbol '$' cannot have a quantifier.");
break :outer RegexUnit(endsWithRegex, null);
},
else => {},

if (!s.escaped) {
switch (s.char) {
'.' => break :outer RegexUnit(anyRegex, q),
'^' => {
if (q != null) @compileError("Symbol '^' cannot have a quantifier.");
break :outer RegexUnit(startsWithRegex, null);
},
'$' => {
if (q != null) @compileError("Symbol '$' cannot have a quantifier.");
break :outer RegexUnit(endsWithRegex, null);
},
else => {},
}
}
}

Expand Down

0 comments on commit f365786

Please sign in to comment.