Torque3D Documentation / _generateds / consoleParser.h

consoleParser.h

Engine/source/console/consoleParser.h

More...

Classes:

class

List of parsers for the compiler.

Namespaces:

namespace

Public Defines

define
CON_ADD_PARSER(prefix, ext, def)    (ext, prefix##GetCurrentFile, prefix##GetCurrentLine, prefix##parse, \
                    prefix##restart, prefix##SetScanBuffer, def)

Helper macro to add console parsers.

define
CON_DECLARE_PARSER(prefix)     char * prefix##GetCurrentFile(); \
    prefix##GetCurrentLine(); \
    prefix##SetScanBuffer( char *sb,  char *fn); \
    prefix##parse(); \
    prefix##restart(FILE *input_file)

Declare a parser's function prototypes.

Detailed Description

Public Defines

CON_ADD_PARSER(prefix, ext, def)    (ext, prefix##GetCurrentFile, prefix##GetCurrentLine, prefix##parse, \
                    prefix##restart, prefix##SetScanBuffer, def)

Helper macro to add console parsers.

CON_DECLARE_PARSER(prefix)     char * prefix##GetCurrentFile(); \
    prefix##GetCurrentLine(); \
    prefix##SetScanBuffer( char *sb,  char *fn); \
    prefix##parse(); \
    prefix##restart(FILE *input_file)

Declare a parser's function prototypes.

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _CONSOLE_PARSER_H_
 25#define _CONSOLE_PARSER_H_
 26
 27#include <stdio.h>
 28
 29/// @ingroup console_system Console System
 30/// @{
 31
 32namespace Compiler
 33{
 34
 35//-----------------------------------------------------------------------------
 36/// \brief Function for GetCurrentFile from the lexer
 37//-----------------------------------------------------------------------------
 38typedef const char *(*fnGetCurrentFile)();
 39//-----------------------------------------------------------------------------
 40/// \brief Function for GetCurrentLine from the lexer
 41//-----------------------------------------------------------------------------
 42typedef S32 (*fnGetCurrentLine)();
 43//-----------------------------------------------------------------------------
 44/// \brief Function for Parse from the lexer
 45//-----------------------------------------------------------------------------
 46typedef S32 (*fnParse)();
 47//-----------------------------------------------------------------------------
 48/// \brief Function for Restart from the lexer
 49//-----------------------------------------------------------------------------
 50typedef void (*fnRestart)(FILE *input_file);
 51//-----------------------------------------------------------------------------
 52/// \brief Function for SetScanBuffer from the lexer
 53//-----------------------------------------------------------------------------
 54typedef void (*fnSetScanBuffer)(const char *sb, const char *fn);
 55
 56//-----------------------------------------------------------------------------
 57/// \brief List of parsers for the compiler
 58//-----------------------------------------------------------------------------
 59struct ConsoleParser
 60{
 61   struct ConsoleParser *next;       //!< Next object in list or NULL
 62
 63   char *ext;                        //!< Filename extension handled by this parser
 64   
 65   fnGetCurrentFile getCurrentFile;  //!< GetCurrentFile lexer function
 66   fnGetCurrentLine getCurrentLine;  //!< GetCurrentLine lexer function
 67   fnParse          parse;           //!< Parse lexer function
 68   fnRestart        restart;         //!< Restart lexer function
 69   fnSetScanBuffer  setScanBuffer;   //!< SetScanBuffer lexer function
 70};
 71
 72// Macros
 73
 74//-----------------------------------------------------------------------------
 75/// \brief Declare a parser's function prototypes
 76//-----------------------------------------------------------------------------
 77#define CON_DECLARE_PARSER(prefix) \
 78   const char * prefix##GetCurrentFile(); \
 79   S32 prefix##GetCurrentLine(); \
 80   void prefix##SetScanBuffer(const char *sb, const char *fn); \
 81   S32 prefix##parse(); \
 82   void prefix##restart(FILE *input_file)
 83
 84//-----------------------------------------------------------------------------
 85/// \brief Helper macro to add console parsers
 86//-----------------------------------------------------------------------------
 87#define CON_ADD_PARSER(prefix, ext, def) \
 88   Compiler::addConsoleParser(ext, prefix##GetCurrentFile, prefix##GetCurrentLine, prefix##parse, \
 89                    prefix##restart, prefix##SetScanBuffer, def)
 90
 91//-----------------------------------------------------------------------------
 92/// \brief Free the console parser list
 93/// 
 94/// \sa AddConsoleParser()
 95//-----------------------------------------------------------------------------
 96void freeConsoleParserList(void);
 97
 98//-----------------------------------------------------------------------------
 99/// \brief Add a console parser to the list
100/// 
101/// \param ext Filename extension
102/// \param gcf GetCurrentFile function
103/// \param gcl GetCurrentLine function
104/// \param p Parse function
105/// \param r Restart function
106/// \param ssb SetScanBuffer function
107/// \param def true if this is the default parser (<b>Note:</b> set this only on the .tscript parser!)
108/// \return true for success, false for failure (out of memory)
109/// \sa FreeConsoleParserList(), ConsoleParser
110//-----------------------------------------------------------------------------
111bool addConsoleParser(char *ext, fnGetCurrentFile gcf, fnGetCurrentLine gcl, fnParse p, fnRestart r, fnSetScanBuffer ssb, bool def = false);
112
113//-----------------------------------------------------------------------------
114/// \brief Get the parser for a particular file based on its extension
115/// 
116/// \param filename Filename of file to obtain parser for
117/// \sa ConsoleParser
118//-----------------------------------------------------------------------------
119ConsoleParser * getParserForFile(const char *filename);
120
121} // end namespace Con
122
123/// @}
124
125#endif // _CONSOLE_PARSER_H_
126