/*
 * xtc - The eXTensible Compiler
 * Copyright (C) 2007 Robert Grimm
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 * USA.
 */

/**
 * Java pattern grammar.
 *
 * @author Robert Grimm
 * @version $Revision: 1.20 $
 */
module xtc.lang.JavaPattern(Core);

modify Core;

Node Pattern =
    <Import>      ImportDeclaration
  / <Field>       FieldDeclaration
  / <Method>      MethodDeclaration
  / <Constructor> ConstructorDeclaration
  / <Class>       ClassDeclaration
  / <Interface>   InterfaceDeclaration
  / <Statement>   Statement
  / <Expression>  yyValue:Expression &{ ! yyValue.hasName("NodeVariable") }
  ;

// Make compilation non-public.
transient generic CompilationUnit := ... ;

Object Name +=
    <Pattern> StringVariable
  / <Name>    ...
  ;

Node Declaration +=
    <Empty>       ...
  / <ListPattern> NodeListVariable
  / <Pattern>     NodeVariable
  ;

generic EnumConstants +=
    <Constants> ...
  / <Patterned> NodeListVariable
  ;

generic Arguments +=
    <Patterned> void:"(":Symbol NodeListVariable void:")":Symbol
  / <Arguments> ...
  ;

Node DeclarationOrStatement +=
    <Statement>   ...
  / <ListPattern> NodeListVariable
  / <Pattern>     NodeVariable
  ;

Node PrimaryExpression +=
    <Nested>  ...
  / <Pattern> NodeVariable
  ;

generic NodeVariable     = void:'#' Word ;
generic StringVariable   = void:'#' Word ;

generic NodeListVariable = void:'#' void:'[' WordCharacters void:']' Spacing ; 
