title: How to fix? Xtext grammar stops parsing with 'no viable alternative at input ...' on incorrect input
body: <p>As an Xtext and Antlr newbie, I'm struggling with getting an error-tolerant Xtext grammar for a very simple subset of a (not JVM related) language I want to parse.</p>
  
  <p>A document in this mini-language could look like this:</p>
  
  <pre><code>$c wff |- $.
  $c class $.
  $c set $.
  </code></pre>
  
  <p>So a sequence of statements surrounded by <code>$c</code> and <code>$.</code> keywords, with inbetween one or more words that may not contain <code>$</code>.  And everything separated by <em>mandatory</em> whitespace.</p>
  
  <p>The best I can come up with is the following grammar:</p>
  
  <pre><code>grammar mm.ecxt.MMLanguage
  
  import "http://www.eclipse.org/emf/2002/Ecore" as ecore
  
  generate mmLanguage "urn:marnix:mm.exct/MMLanguage"
  
  MMDatabase:
      WS? (statements+=statement WS)* statements+=statement WS?;
  
  statement:
      DOLLAR_C WS (symbols+=MATHSYMBOL WS)+ DOLLAR_DOT;
  
  terminal DOLLAR_C: '$c';
  terminal DOLLAR_DOT: '$.';
  terminal MATHSYMBOL: 
        ('!'..'#'|'%'..'~')+; /* everything except '$' */
  
  terminal WS : (' '|'\t'|'\r'|'\n')+;
  
  terminal WORD: ('!'..'~')+;
  </code></pre>
  
  <p>On valid input this grammar works fine.  However, on invalid input, like</p>
  
  <pre><code>$c class $.
  $c $.
  $c set $.
  $c x$u $.
  </code></pre>
  
  <p>there is just one error (<code>no viable alternative at input '$.'</code>), and after that it looks like parsing just stops: no more errors are detected, and the model just contains the correct statements before the error (here only the <code>class</code> statement).</p>
  
  <p>I tried all kinds of variations (using <code>=&gt;</code>, with/without <code>terminal</code> declarations, enabling backtracking, and more) but all I get is <code>no viable alternative at input ...</code>.</p>
  
  <p><strong>So my question is:</strong> How should I write a grammar for this language so that Antlr does some form of error recovery?  Or is there something else that I'm doing wrong?</p>
  
  <p>From, e.g., <a href="http://zarnekow.blogspot.de/2012/11/xtext-corner-7-parser-error-recovery.html" rel="nofollow">http://zarnekow.blogspot.de/2012/11/xtext-corner-7-parser-error-recovery.html</a> I expected that this would work out of the box.  Or is this because I'm not using a Java/C-like grammar based on Xbase?</p>