module SQLiterate

grammar Query
  include Space
  include Keywords
  include Expression

  rule query
    space with_section space query_expression space <Node::Query>
  end

  rule with_section
    (with_kw space with_queries / space) <Node::WithSection>
  end

  rule with_queries
    with_query r:( space ',' space with_query )* <Node::WithQueries>
  end

  rule with_query
    identifier space as_kw space '('
      space query_expression space
    ')' <Node::WithQuery>
  end
end

end