Kaynağa Gözat

Add sequence and alternation

WitherFlower 1 yıl önce
ebeveyn
işleme
ab36bf8e07
1 değiştirilmiş dosya ile 31 ekleme ve 0 silme
  1. +31
    -0
      grammar_parser.meta

+ 31
- 0
grammar_parser.meta Dosyayı Görüntüle

@ -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);

Yükleniyor…
İptal
Kaydet