Quellcode durchsuchen

Add sequence and alternation

Ursprung
Commit
e05ae647c7
1 geänderte Dateien mit 31 neuen und 0 gelöschten Zeilen
  1. +31
    -0
      grammar_parser.meta

+ 31
- 0
grammar_parser.meta Datei anzeigen

@ -226,6 +226,37 @@ Not.match(stream, context, actions) {
}
}
// Sequence
Sequence = Object.subtype(#Sequence);
Sequence.match(stream, context, actions) {
i = 0;
match = 1;
while (i < self.length() && match == 1) {
match = self[i].match(stream, context, actions);
}
match;
}
// Alternation
Alternation = Object.subtype(#Alternation);
Alternation.match(stream, context, actions) {
i = 0;
match = 0;
while(i < self.length() && match == 0){
initialActionCount = actions.length();
match = self[i].match(stream, context, actions);
if (match == 0) {
while (actions.length() > initialActionCount) {
actions.pop();
}
}
}
}
// Action
Action = Object.subtype(#Action);

Laden…
Abbrechen
Speichern