Browse Source

Use newest primitives for character class and string matching

master
MaximeBarniaudy 11 months ago
parent
commit
3ef49024c5
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      grammar_parser.meta

+ 3
- 3
grammar_parser.meta View File

@ -131,7 +131,7 @@ Object.last() { self[self.length() - 1] }
//}
//Stream.atEnd() { self.position >= self.limit }
Stream.peek() { !self.atEnd() && self.content[self.position] }
Stream.peek() { self.content[self.position] }
//Stream.inc() { !self.atEnd() && { self.position = self.position + 1; } }
//Stream.setLastBegin = () { self.lastBegin = self.position; };
@ -170,7 +170,7 @@ StringLiteral.match(stream, context, actions) {
StringLiteral.getMatchingExpression() {
//return `(@stream).match(@self.string) && ((@stream).position += len(@self.string)) && @true;
return `{
if (stream.match(@self.string)) {
if (stream.content.compareFrom(stream.position, @self.string) == 0) {
stream.position += len(@self.string);
@true;
} else {
@ -330,7 +330,7 @@ CharacterClass.staticmatch(stream, context, actions, value) {
CharacterClass.getMatchingExpression() {
//return `CharacterClass.staticmatch(@stream, @context, @actions, @self.value);
return `{ CharacterClass.staticmatch(stream, context, actions, @self.value) };
return `{ !stream.atEnd() && (@self.value).charClass().bitTest(stream.peek()) && stream.inc() && @true };
}
// Dot

Loading…
Cancel
Save