/*
 * 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.
 */
 
/**
 * Definition of Typical identifiers.
 *
 * @author Laune Harris, Anh Le
 * @version $Revision: 1.9 $
 */
module xtc.typical.Identifier(Spacing);

import Spacing; 
 
body { 
  static {
     add(TYPICAL_KEYWORDS, new String[] 
        {"and", "any", "assert", "require", "attribute",
         "bool", "bottom", "else", "error", "equality",
         "float", "float32", "float64", "as", "if", "in",
         "int", "guard", "mlvalue", "match", "namespace", 
         "of", 
         "scope", "string",
         "symbol", "mltype",
         "warning", "when", "with" ,"reduce", "then",
         "to", "true", "false", "sig", "modify", 
         "module", "_", "predicate", "instantiate",
         "import", "eqattribute", "function", "fun", "let",
         "at", "begin", "end", "default", "Node"}
     );
  } 
}  

option setOfString(TYPICAL_KEYWORDS) ;

String LowerIdentifier =
    yyValue:LowerWord &{ ! TYPICAL_KEYWORDS.contains(yyValue) } Spacing 
  ;

String UpperIdentifier =
    yyValue:UpperWord &{ ! TYPICAL_KEYWORDS.contains(yyValue) } Spacing
  ;

String Identifier =
    yyValue:Word &{ ! TYPICAL_KEYWORDS.contains(yyValue) } Spacing
  ;

String LowerWord = [a-z_] [a-zA-Z0-9_]* ;
String UpperWord = [A-Z_] [a-zA-Z0-9_]* ;
String Word = [a-zA-Z_] [a-zA-Z0-9_]* ;

String Keyword = 
    yyValue:Word &{ TYPICAL_KEYWORDS.contains(yyValue) } Spacing
  ; 
