#
#  File: tokens.k3
#  Defines the tokens recognized by the AGFL lexer
#
#  Copyright 2005 Radboud University of Nijmegen
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  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 Library 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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#  CVS ID: "$Id: tokens.k3,v 1.6 2005/10/26 13:36:55 marcs Exp $"
#
MODULE tokens.

DEFINES TOKEN,
        FUNCTION convert >TOKEN to TEXT>.

#
# Tokens and token conversion
#
TOKEN :: unknown token;
         identifier part TEXT;
	 special name TEXT;
         quoted string TEXT;
         dot number INT;
         number INT;
         grammar symbol;
         defines symbol;
         lexicon symbol;
         includes symbol;
         root symbol;
         cond symbol;
         rule symbol;
         option symbol;
         left parenthesis;
         left curly bracket;
         left square bracket;
         right parenthesis;
	 right sharp bracket;
         right curly bracket;
         right square bracket;
         commit;
         ampersand;
         comma;
         period;
         slash;
         double colon;
         colon;
         semicolon;
         bar;
         end of file.

FUNCTION convert >TOKEN to TEXT>:
   [ TOKEN -> unknown token ],		[ "unknown token" -> TEXT ];
   [ TOKEN -> identifier part TEXT ];
   [ TOKEN -> special name TEXT1 ],	[ "$" + TEXT1 -> TEXT ];
   [ TOKEN -> quoted string TEXT1 ],	[ "\"" + TEXT1 + "\"" -> TEXT ];
   [ TOKEN -> number INT ],
	bindec  (INT, TEXT1), [ "number" + TEXT1 -> TEXT ];
   [ TOKEN -> grammar symbol ],		[ "GRAMMAR" -> TEXT ];
   [ TOKEN -> lexicon symbol ],		[ "LEXICON" -> TEXT ];
   [ TOKEN -> defines symbol ],		[ "DEFINES" -> TEXT ];
   [ TOKEN -> includes symbol ],	[ "INCLUDES" -> TEXT ];
   [ TOKEN -> root symbol ],		[ "ROOT" -> TEXT ];
   [ TOKEN -> cond symbol ],		[ "COND" -> TEXT ];
   [ TOKEN -> rule symbol ],		[ "RULE" -> TEXT ];
   [ TOKEN -> option symbol ],		[ "OPTION" -> TEXT ];
   [ TOKEN -> double colon ],		[ "::" -> TEXT ];
   [ TOKEN -> colon ],			[ ":" -> TEXT ];
   [ TOKEN -> bar ],			[ "|" -> TEXT ];
   [ TOKEN -> comma ],			[ "," -> TEXT ];
   [ TOKEN -> left parenthesis ],	[ "(" -> TEXT ];
   [ TOKEN -> left curly bracket ],	[ "{" -> TEXT ];
   [ TOKEN -> left square bracket ],	[ "[" -> TEXT ];
   [ TOKEN -> right parenthesis ],	[ ")" -> TEXT ];
   [ TOKEN -> right sharp bracket ],	[ ">" -> TEXT ];
   [ TOKEN -> right curly bracket ],	[ "}" -> TEXT ];
   [ TOKEN -> right square bracket ],	[ "]" -> TEXT ];
   [ TOKEN -> semicolon ],		[ ";" -> TEXT ];
   [ TOKEN -> period ],			[ "." -> TEXT ];
   [ TOKEN -> commit ],			[ "!" -> TEXT ];
   [ TOKEN -> slash ],			[ "/" -> TEXT ];
   [ TOKEN -> ampersand ],		[ "&" -> TEXT ];
   [ TOKEN -> end of file ],		[ "end of file" -> TEXT ];
   ?.
