/* Objective Modula-2 Compiler Utility Program (gen_first_and_follow_sets.c) * * @file objm2_tokenset_literals.h * Literal generator interface * * Tokenset initialiser literal generator * * Author: Benjamin Kowarsch * * Copyright (C) 2009 The Objective Modula-2 Project. All rights reserved. * * License: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met * * 1) This file, or any part thereof, may NOT be hosted on websites which * contain advertising, unless specific prior written permission has been * obtained. The licensor will grant such permission upon request at its * sole discretion to websites the licensor does NOT consider abusive in * their use of advertising. Small notices in the footer of a website * naming corporate rights holders, infrastructure providers or sponsors * are not considered advertising in the context of this license. * * 2) Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 3) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and other materials provided with the distribution. * * 4) Neither the author's name nor the names of any contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * 5) Where this list of conditions or the following disclaimer, in part or * as a whole is overruled or nullified by applicable law, no permission * is granted to use the software. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Version history: * * 2.00 2009-08-15 BK new file */ #include "objm2_tokens.h" #include "objm2_tokenset.h" #include "objm2_build_params.h" // -------------------------------------------------------------------------- // Status codes // -------------------------------------------------------------------------- typedef enum /* objm2_tokenset_literal_status_t */ { OBJM2_TOKENSET_LITERAL_STATUS_SUCCESS = 0, OBJM2_TOKENSET_LITERAL_STATUS_INVALID_REFERENCE, OBJM2_TOKENSET_LITERAL_STATUS_INVALID_TOKENSET_SIZE, OBJM2_TOKENSET_LITERAL_STATUS_OUT_OF_RANGE } objm2_tokenset_literal_status_t; // -------------------------------------------------------------------------- // Size and string type for tokenset literals // -------------------------------------------------------------------------- // // tokenset-literal := tuple ( ", " tuple )* // // tuple := "0x" digit digit digit digit digit digit digit digit // // digit := "0" .. "9" | "A" .. "F" // // length of literal = tuples * 10 + (tuples - 1) * 2 // number of tuples = number of tokenset segments // storage size = length + 1 #define OBJM2_TOKENSET_LITERAL_LENGTH \ ((OBJM2_TOKENSET_LITERAL_NUM_OF_TUPLES * 10) \ + ((OBJM2_TOKENSET_LITERAL_NUM_OF_TUPLES - 1) * 2)) #define OBJM2_TOKENSET_LITERAL_NUM_OF_TUPLES \ OBJM2_TOKENSET_SEGMENTS_PER_SET typedef char objm2_tokenset_literal_t[OBJM2_TOKENSET_LITERAL_LENGTH + 1]; // --------------------------------------------------------------------------- // function: objm2_tokenset_to_literal( set, literal, status ) // --------------------------------------------------------------------------- // // Passes a C string containing an initialiser literal for tokenset back // in parameter . If is NULL, an empty string is passed back. // If is NULL, the function returns without action. void objm2_tokenset_to_literal(objm2_tokenset_t set, objm2_tokenset_literal_t *literal, objm2_tokenset_literal_status_t *status); // END OF FILE