/* Objective Modula-2 Compiler (objm2c) * * objm2_productions.c * Implementation of productions * * Author: Benjamin Kowarsch * * Copyright (C) 2009 The Objective Modula-2 Project. 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-09-20 BK new file */ #include #include "common_macros.h" #include "objm2_productions.h" // --------------------------------------------------------------------------- // Human readable names of productions // --------------------------------------------------------------------------- // // Only the first macro parameter is used, all other parameters are ignored. typedef char *objm2_production_name_t; #define _add_production(_production, \ _fi0, _fi1, _fi2, _fi3, _fo0, _fo1, _fo2, _fo3) \ static const char _PRODNAM ## _production[] = # _production EMPTY_STRING; #include "objm2_production_table.h" #undef _add_production // --------------------------------------------------------------------------- // Table of human readable production names // --------------------------------------------------------------------------- // // Only the first macro parameter is used, all other parameters are ignored. // Each string's address is incremented to skip the preceeding underscore. #define _add_production(_production, \ _fi0, _fi1, _fi2, _fi3, _fo0, _fo1, _fo2, _fo3) \ (char *)&_PRODNAM ## _production + 1, static const objm2_production_name_t objm2_production_name_str[] = { #include "objm2_production_table.h" } /* objm2_production_name_str */; #undef _add_production // --------------------------------------------------------------------------- // function: objm2_production_name( production ) // --------------------------------------------------------------------------- // // Returns the human readable name for production . // Returns NULL if the value of is invalid. const char *objm2_production_name(objm2_production_t production) { if (production < OBJM2_NUMBER_OF_PRODUCTIONS) return objm2_production_name_str[production]; else return NULL; } // end objm2_production_name // END OF FILE