/* Objective Modula-2 Compiler (objm2c) * * objm2_tokens.h * Definition of compiler tokens and their values * * Author: Benjamin Kowarsch * * Copyright (C) 2009 Sunrise Telephone Systems KK. All rights reserved. * * License: * * Permission is hereby granted to review and test this software for the sole * purpose of supporting the effort by the licensor to define and develop the * Objective Modula-2 language. It is not permissible under any circumstances * to use the software for the purpose of creating derivative languages or * dialects. This permission is valid until 31 December 2009, 24:00h GMT. * * Future licensing: * * The licensor undertakes to eventually release this software under a proper * open source license AFTER the Objective Modula-2 language definition has * been finalised and a conforming and working reference compiler completed. * * Version history: * * 2.00 2009-01-31 BK new file */ #ifndef OBJM2_TOKENS_H #define OBJM2_TOKENS_H // --------------------------------------------------------------------------- // Total number of tokens // --------------------------------------------------------------------------- #define OBJM2_NUMBER_OF_TOKENS _OBJM2_NUMBER_OF_TOKENS // --------------------------------------------------------------------------- // Enumeration type containing all tokens // --------------------------------------------------------------------------- #define _add_token(_suffix, _desc) TOKEN ## _suffix, #define _add_reserved_word(_suffix, _hash) TOKEN ## _suffix, typedef /* objm2_token_t */ enum { // first entry for illegal input TOKEN_ILLEGAL_CHARACTER = 0, // insert reserved word tokens from reserved word master table #include "objm2__reserved_word_table.h" // insert all other tokens from token master table #include "objm2_token_table.h" // final entry to obtain total number of tokens _OBJM2_NUMBER_OF_TOKENS } objm2_token_t; #undef _add_token #undef _add_reserved_word // -------------------------------------------------------------------------- // Token aliases for convenience // -------------------------------------------------------------------------- #define TOKEN_ILLEGAL_CHAR TOKEN_ILLEGAL_CHARACTER #define TOKEN_IDENT TOKEN_IDENTIFIER #define TOKEN_COLON_IDENT TOKEN_COLON_IDENTIFIER #define TOKEN_NUM_LITERAL TOKEN_NUMERIC_LITERAL #define TOKEN_STR_LITERAL TOKEN_STRING_LITERAL #define TOKEN_LPAREN TOKEN_OPENING_PARENTHESIS #define TOKEN_RPAREN TOKEN_CLOSING_PARENTHESIS #define TOKEN_LBRACKET TOKEN_OPENING_SQUARE_BRACKET #define TOKEN_RBRACKET TOKEN_CLOSING_SQUARE_BRACKET #define TOKEN_LBRACE TOKEN_OPENING_CURLY_BRACE #define TOKEN_RBRACE TOKEN_CLOSING_CURLY_BRACE // --------------------------------------------------------------------------- // function: objm2_token_name(token) // --------------------------------------------------------------------------- // // Returns the human readable name for token . // Returns NULL if the value of is invalid. const char *objm2_token_name(objm2_token_t token); #endif /* OBJM2_TOKENS_H */ // END OF FILE