/*
 * 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.
 */

/**
 * Grammar for AST definitions.
 *
 * @author Robert Grimm
 * @version $Revision: 1.1 $
 */
module xtc.parser.AstDefinition;

import xtc.util.Spacing;

option withLocation, constant, parser(xtc.parser.AstDefParser);

public generic Definition =
  Spacing void:"mltype":Word void:"node":Word void:"=":Symbol 
  Constructor* void:";":Symbol
  ;

generic Constructor = void:"|":Symbol Word Members? ;

generic Members = void:"of":Word Type (void:"*":Symbol Type)+ ;

Node Type =
    <Option>    OptionType
  / <List>      ListType
  / <Primitive> PrimitiveType
  ;

generic OptionType = void:"(":Symbol Type void:"option":Word void:")":Symbol ;
generic ListType   = void:"(":Symbol Type void:"list":Word   void:")":Symbol ;

generic PrimitiveType =
    <Node>   "node":Word
  / <String> "string":Word
  / <Any>    "any":Word
  ;

String Word = WordCharacters Spacing ;
transient String WordCharacters = [a-zA-Z] ( [_]+ [a-zA-Z0-9] / [a-zA-Z0-9] )* ;

String Symbol = SymbolCharacters Spacing ;
transient String SymbolCharacters = "=" / "|" / "*" / "(" / ")" / ";" ;