diff --git a/grammar_parser.meta b/grammar_parser.meta index e692d62..004ea28 100644 --- a/grammar_parser.meta +++ b/grammar_parser.meta @@ -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);