/*
 * xtc - The eXTensible Compiler
 * Copyright (C) 2007 New York University
 *
 * 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.
 */

/**
 * Grammar for the Overlog language.
 *
 * @author Robert Soule
 * @version $Revision: 1.3 $
 * 
 */
module xtc.lang.overlog.Identifier(Spacing, Reserved);

import Spacing;
import Reserved;

Node Identifier =
    <VariableIdentifier>  VariableIdentifier
  / <FunctionIdentifier>  FunctionIdentifier
  / <UnnamedIdentifier>   UnnamedIdentifier
  ;

//  / <AggregateIdentifier> AggregateIdentifier

generic RuleIdentifier = RuleName ;

String RuleName =
  yyValue:Word &{ ! contains(OVERLOG_KEYWORDS, yyValue) } ;

String Word = WordCharacters Spacing ;
transient String WordCharacters = 
    TupleNameCharacters 
  / QualifiedTupleNameCharacters 
  ;

String TupleNameCharacters = [a-z][a-zA-Z0-9]* ;
String QualifiedTupleNameCharacters = ':'':'[a-zA-Z0-9]* ;

generic VariableIdentifier = VariableName Spacing;

String VariableName = [A-Z][a-zA-Z0-9]* ;

generic FunctionIdentifier = FunctionName Spacing; 

String FunctionName = 'f''_'[a-zA-Z0-9]+ ;

generic AggregateIdentifier = AggregateName ;

String AggregateName = 'a''_'[_a-zA-Z0-9]+ ;

generic UnnamedIdentifier = UnnamedIdentifierName Spacing;

String UnnamedIdentifierName = [_*] ;

