Your grammar does not allow the list in that location. Here is the
relevant excerpt:
```
:start ::= language
#
# include begin
language ::= if_statement action_statements action => ifAction
| action_statements action => verbAction
| ('List') variable ('is') comma_list action =>
listAction
```
So you say that a document can
EITHER be an if-statement followed by any number of action statements,
OR any number of action statements,
OR a List statement.
This is why testing a List statement by itself works fine. But in your
input, you have an if-statement that includes one action statement,
followed by an unexpected List statement:
```
If documentTitle = A100
remove Document
List Author is Dante, Murakami, Ash, Harris
```
Instead, you would likely want to change your grammar so that you can
have multiple statements of different type, for example:
```
language ::= statement*
statement ::= if_statement | action | list_statement
```
But this might become ambiguous. For example, consider this input:
```
If foo = bar
remove Doc1
remove Doc2
```
Should the `remove Doc2` action be within the if-statement, or should it
be an unconditional action? In your current grammar, both actions would
be part of the if-statement. In my suggested grammar, both are allowed
and the parse is ambiguous.
This problem is solved most easily if you can change your language to
have explicit delimiters, e.g. curly braces:
```
If foo = bar {
remove Doc1
}
remove Doc2
```
or other compound statement terminators, e.g. an `End` like in Ruby or Lua:
```
If foo = bar
remove Doc1
End
remove Doc2
```
Of course, many languages use the indentation level to indicate nesting,
for example Python or YAML. Marpa has no built-in features for
indentation-sensitive parsing. If you are trying to parse an existing
format or really want to use indentation to indicate the scope of the
conditional, you would have to use Marpa's event system to handle
indentation. You could use the same trick that Python uses: having
special/invisible INDENT and DEDENT tokens that mark where the indented
block begins and ends. These tokens are emitted whenever the indentation
changes. In the grammar, these tokens can then be used just like curly
braces in curly-brace languages. For example, you might then define your
if-statement like:
```
if_statement ::= ('If') condition (INDENT) action_statements (DEDENT)
```
--
You received this message because you are subscribed to the Google Groups "marpa
parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to marpa-parser+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/marpa-parser/71c6eb23-b33d-7003-1342-5781e1dc0dc5%40LukasAtkinson.de.