title: ANTLR : no viable alternative error
body: <p>I have a task to write simple parser-generator, so I wrote ANTLR-like grammar and tried to parse simple file like "foo:bar;", but got the following output:</p>
  
  <pre><code>[@0,0:2='foo',&lt;1&gt;,1:0]
  [@1,3:3=':',&lt;16&gt;,1:3]
  [@2,4:6='bar',&lt;1&gt;,1:4]
  [@3,7:7=';',&lt;18&gt;,1:7]
  [@4,8:7='&lt;EOF&gt;',&lt;-1&gt;,1:8]
  line 1:0 no viable alternative at input 'foo'
  (rule foo : bar ;)
  </code></pre>
  
  <p>My grammar looks like</p>
  
  <pre><code>grammar parsGen;
  
  gram : rule SEMICOLON (NEWLINE+ rule SEMICOLON)* ;
  
  rule : lRule | pRule ;
  
  lRule : LRULEID COLON lRule1 ;
  lRule1 : (((LRULEID | STRING | SET) | LBRACE lRule1 PIPE lRule1 RBRACE) modificator? SPACE+)+ ;
  
  pRule : PRULEID COLON pRule1 ;
  pRule1 : (((LRULEID | PRULEID) | LBRACE lRule1 PIPE lRule1 RBRACE) modificator? SPACE+)+ ;
  
  modificator : PLUS | ASTERISK | QUESTION ;
  
  ID : LRULEID | PRULEID ;
  
  LRULEID : UPPERLETTER (UPPERLETTER | LOWERLETTER | DIGIT)* ;
  PRULEID : LOWERLETTER (UPPERLETTER | LOWERLETTER | DIGIT)* ;
  
  STRING : ('\''.*?'\'') ;
  SET : '\''.*?'\'..\''.*?'\'' ;
  
  UPPERLETTER : [A-Z] ;
  LOWERLETTER : [a-z] ;
  DIGIT : [0-9] ;
  
  NEWLINE : '\r\n'|'\n'|'\r' ;
  
  PLUS : '+' ;
  ASTERISK : '*' ;
  QUESTION : '?' ;
  
  LBRACE : '(' ;
  RBRACE : ')' ;
  
  SPACE : ' ' ;
  
  COLON : ':' ;
  
  PIPE : '|' ;
  
  SEMICOLON : ';' ;
  </code></pre>
  
  <p>So where could I make a mistake? I tried to search everywhere (google, SO etc.) error "no viable alternative", but it didn't really help me.</p>