title: JavaCC: treat white space like <OR>
body: <p>I'm trying to build a simple grammar for Search Engine query.
  I've got this so far -</p>
  
  <pre><code>options {
    STATIC=false;
    MULTI=true;
    VISITOR=true;
  }
  
  PARSER_BEGIN(SearchParser)
  package com.syncplicity.searchservice.infrastructure.parser;
  public class SearchParser {}
  PARSER_END(SearchParser)
  
  SKIP :
  {
    " "
  | "\t"
  | "\n"
  | "\r"
  }
  
  &lt;*&gt; TOKEN : {
    &lt;#_TERM_CHAR:       ~[ " ", "\t", "\n", "\r", "!", "(", ")", "\"", "\\", "/" ] &gt;
  | &lt;#_QUOTED_CHAR:     ~["\""] &gt;
  | &lt;#_WHITESPACE:      ( " " | "\t" | "\n" | "\r" | "\u3000") &gt;
  }
  
  TOKEN :
  {
    &lt;AND:              "AND"&gt;
  | &lt;OR:               "OR"&gt;
  | &lt;NOT:              ("NOT" | "!")&gt;
  | &lt;LBRACKET:         "("&gt;
  | &lt;RBRACKET:         ")"&gt;
  | &lt;TERM:             (&lt;_TERM_CHAR&gt;)+ &gt;
  | &lt;QUOTED:           "\"" (&lt;_QUOTED_CHAR&gt;)+ "\""&gt;
  }
  
  /** Main production. */
  
  ASTQuery query() #Query: {}
  {
    subQuery()
    ( &lt;AND&gt; subQuery() #LogicalAnd
    | &lt;OR&gt; subQuery() #LogicalOr
    | &lt;NOT&gt; subQuery() #LogicalNot
    )*
    {
      return jjtThis;
    }
  }
  
  void subQuery() #void: {}
  {
    &lt;LBRACKET&gt; query() &lt;RBRACKET&gt; | term() | quoted()
  }
  
  void term() #Term:
  {
    Token t;
  }
  {
    (
      t=&lt;TERM&gt;
    )
    {
      jjtThis.value = t.image;
    }
  }
  
  void quoted() #Quoted:
  {
    Token t;
  }
  {
    (
      t=&lt;QUOTED&gt;
    )
    {
      jjtThis.value = t.image;
    }
  }
  </code></pre>
  
  <p>Looks like it works as I wanted to, e.g it can handle <code>AND, OR, NOT/!</code>, single terms and quoted text.</p>
  
  <p>However I can't force it to handle whitespaces between terms as <code>OR</code> operator. E.g <code>hello world</code> should be treated as <code>hello OR world</code></p>
  
  <p>I've tried all obvious solutions, like <code>&lt;OR: ("OR" | " ")&gt;</code>, removing <code>" "</code> from <code>SKIP</code>, etc. But it still doesn't work.</p>