diff options
author | albert-github <albert.tests@gmail.com> | 2019-09-05 12:04:14 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2019-09-05 12:04:14 (GMT) |
commit | aca16ea3b4e4beef9bf067d0b532dfa3802f7a3d (patch) | |
tree | 9c040ab60c4d6f7c1bd3503abb1b2f6d219d86f2 /src | |
parent | 98cc801013b16d827d91567998ead7b24fd78b6d (diff) | |
download | Doxygen-aca16ea3b4e4beef9bf067d0b532dfa3802f7a3d.zip Doxygen-aca16ea3b4e4beef9bf067d0b532dfa3802f7a3d.tar.gz Doxygen-aca16ea3b4e4beef9bf067d0b532dfa3802f7a3d.tar.bz2 |
Consistent way to show scanner state
Create a consistent way to display the state mnemonics of the different scanners (analogous to the fortranscanner.l)
Use an automatic procedure to generate the routine with the translation of the states to a string.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 103 | ||||
-rw-r--r-- | src/code.l | 3 | ||||
-rw-r--r-- | src/commentcnv.l | 3 | ||||
-rw-r--r-- | src/commentscan.l | 3 | ||||
-rw-r--r-- | src/configimpl.l | 3 | ||||
-rw-r--r-- | src/constexp.l | 2 | ||||
-rw-r--r-- | src/declinfo.l | 2 | ||||
-rw-r--r-- | src/defargs.l | 2 | ||||
-rw-r--r-- | src/doctokenizer.l | 2 | ||||
-rw-r--r-- | src/fortrancode.l | 3 | ||||
-rw-r--r-- | src/fortranscanner.l | 45 | ||||
-rw-r--r-- | src/pre.l | 3 | ||||
-rw-r--r-- | src/pycode.l | 2 | ||||
-rw-r--r-- | src/pyscanner.l | 2 | ||||
-rw-r--r-- | src/scan_states.py | 53 | ||||
-rw-r--r-- | src/scanner.l | 2 | ||||
-rw-r--r-- | src/sqlcode.l | 2 | ||||
-rw-r--r-- | src/tclscanner.l | 3 | ||||
-rw-r--r-- | src/vhdlcode.l | 4 | ||||
-rw-r--r-- | src/xmlcode.l | 3 |
20 files changed, 167 insertions, 78 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7233052..029b613 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,25 +100,39 @@ add_custom_command( ) set_source_files_properties(${GENERATED_SRC}/layout_default.xml.h PROPERTIES GENERATED 1) -# Targets for flex/bison generated files -FLEX_TARGET(scanner scanner.l ${GENERATED_SRC}/scanner.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(code code.l ${GENERATED_SRC}/code.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(pyscanner pyscanner.l ${GENERATED_SRC}/pyscanner.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(pycode pycode.l ${GENERATED_SRC}/pycode.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(fortranscanner fortranscanner.l ${GENERATED_SRC}/fortranscanner.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(fortrancode fortrancode.l ${GENERATED_SRC}/fortrancode.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(vhdlcode vhdlcode.l ${GENERATED_SRC}/vhdlcode.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(tclscanner tclscanner.l ${GENERATED_SRC}/tclscanner.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(pre pre.l ${GENERATED_SRC}/pre.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(declinfo declinfo.l ${GENERATED_SRC}/declinfo.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(defargs defargs.l ${GENERATED_SRC}/defargs.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(doctokenizer doctokenizer.l ${GENERATED_SRC}/doctokenizer.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(commentcnv commentcnv.l ${GENERATED_SRC}/commentcnv.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(commentscan commentscan.l ${GENERATED_SRC}/commentscan.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(constexp constexp.l ${GENERATED_SRC}/constexp.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(xmlcode xmlcode.l ${GENERATED_SRC}/xmlcode.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(sqlcode sqlcode.l ${GENERATED_SRC}/sqlcode.cpp COMPILE_FLAGS "${LEX_FLAGS}") -FLEX_TARGET(configimpl configimpl.l ${GENERATED_SRC}/configimpl.cpp COMPILE_FLAGS "${LEX_FLAGS}") +set(LEX_FILES scanner + code + pyscanner + pycode + fortranscanner + fortrancode + vhdlcode + tclscanner + pre + declinfo + defargs + doctokenizer + commentcnv + commentscan + constexp + xmlcode + sqlcode + configimpl) + +# unfortunately ${LEX_FILES_H} and ${LEX_FILES_CPP} don't work in older versions of CMake (like 3.6.2) for add_library +foreach(lex_file ${LEX_FILES}) + set(LEX_FILES_H ${LEX_FILES_H} " " ${GENERATED_SRC}/${lex_file}.l.h CACHE INTERNAL "Stores generated files") + set(LEX_FILES_CPP ${LEX_FILES_CPP} " " ${GENERATED_SRC}/${lex_file}.cpp CACHE INTERNAL "Stores generated files") + add_custom_command( + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/scan_states.py ${CMAKE_SOURCE_DIR}/src/${lex_file}.l > ${GENERATED_SRC}/${lex_file}.l.h + DEPENDS ${CMAKE_SOURCE_DIR}/src/scan_states.py ${CMAKE_SOURCE_DIR}/src/${lex_file}.l + OUTPUT ${GENERATED_SRC}/${lex_file}.l.h + ) + set_source_files_properties(${GENERATED_SRC}/${lex_file}.l.h PROPERTIES GENERATED 1) + + FLEX_TARGET(${lex_file} ${lex_file}.l ${GENERATED_SRC}/${lex_file}.cpp COMPILE_FLAGS "${LEX_FLAGS}") +endforeach() + BISON_TARGET(constexp constexp.y ${GENERATED_SRC}/ce_parse.cpp COMPILE_FLAGS "${YACC_FLAGS}") @@ -140,24 +154,45 @@ add_library(_doxygen STATIC ${GENERATED_SRC}/ce_parse.h ${GENERATED_SRC}/configvalues.h ${GENERATED_SRC}/resources.cpp - # generated by flex/bison - ${GENERATED_SRC}/scanner.cpp + # generated for/by flex/bison + #${LEX_FILES_H} #unfortunately doesn't work in older versions of CMake (like 3.6.2) + #${LEX_FILES_CPP} #unfortunately doesn't work in older versions of CMake (like 3.6.2) + ${GENERATED_SRC}/code.l.h + ${GENERATED_SRC}/commentcnv.l.h + ${GENERATED_SRC}/commentscan.l.h + ${GENERATED_SRC}/configimpl.l.h + ${GENERATED_SRC}/constexp.l.h + ${GENERATED_SRC}/declinfo.l.h + ${GENERATED_SRC}/defargs.l.h + ${GENERATED_SRC}/doctokenizer.l.h + ${GENERATED_SRC}/fortrancode.l.h + ${GENERATED_SRC}/fortranscanner.l.h + ${GENERATED_SRC}/pre.l.h + ${GENERATED_SRC}/pycode.l.h + ${GENERATED_SRC}/pyscanner.l.h + ${GENERATED_SRC}/scanner.l.h + ${GENERATED_SRC}/sqlcode.l.h + ${GENERATED_SRC}/tclscanner.l.h + ${GENERATED_SRC}/vhdlcode.l.h + ${GENERATED_SRC}/xmlcode.l.h ${GENERATED_SRC}/code.cpp - ${GENERATED_SRC}/pyscanner.cpp - ${GENERATED_SRC}/pycode.cpp - ${GENERATED_SRC}/fortranscanner.cpp - ${GENERATED_SRC}/fortrancode.cpp - ${GENERATED_SRC}/vhdlcode.cpp - ${GENERATED_SRC}/tclscanner.cpp - ${GENERATED_SRC}/pre.cpp - ${GENERATED_SRC}/declinfo.cpp - ${GENERATED_SRC}/defargs.cpp - ${GENERATED_SRC}/doctokenizer.cpp ${GENERATED_SRC}/commentcnv.cpp ${GENERATED_SRC}/commentscan.cpp + ${GENERATED_SRC}/configimpl.cpp ${GENERATED_SRC}/constexp.cpp - ${GENERATED_SRC}/xmlcode.cpp + ${GENERATED_SRC}/declinfo.cpp + ${GENERATED_SRC}/defargs.cpp + ${GENERATED_SRC}/doctokenizer.cpp + ${GENERATED_SRC}/fortrancode.cpp + ${GENERATED_SRC}/fortranscanner.cpp + ${GENERATED_SRC}/pre.cpp + ${GENERATED_SRC}/pycode.cpp + ${GENERATED_SRC}/pyscanner.cpp + ${GENERATED_SRC}/scanner.cpp ${GENERATED_SRC}/sqlcode.cpp + ${GENERATED_SRC}/tclscanner.cpp + ${GENERATED_SRC}/vhdlcode.cpp + ${GENERATED_SRC}/xmlcode.cpp # ${GENERATED_SRC}/ce_parse.cpp # @@ -251,6 +286,10 @@ add_library(_doxygen STATIC docgroup.cpp ) +##foreach(lex_file ${LEX_FILES}) +##add_library(_doxygen STATIC ${GENERATED_SRC}/${lex_file}.l.h) +##endforeach() + add_executable(doxygen main.cpp) if (use_libclang) @@ -165,6 +165,8 @@ static int g_braceCount=0; static void saveObjCContext(); static void restoreObjCContext(); +static const char *stateToString(int state); + static QCString g_forceTagReference; @@ -3875,3 +3877,4 @@ extern "C" { // some bogus code to keep the compiler happy #error "You seem to be using a version of flex newer than 2.5.4. These are currently incompatible with 2.5.4, and do NOT work with doxygen! Please use version 2.5.4 or expect things to be parsed wrongly! A bug report has been submitted (#732132)." #endif +#include "code.l.h" diff --git a/src/commentcnv.l b/src/commentcnv.l index 2550227..f144aec 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -94,6 +94,8 @@ static bool g_vhdl; // for VHDL old style --! comment static SrcLangExt g_lang; static bool isFixedForm; // For Fortran +static const char *stateToString(int state); + static void replaceCommentMarker(const char *s,int len) { const char *p=s; @@ -1145,3 +1147,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "commentcnv.l.h" diff --git a/src/commentscan.l b/src/commentscan.l index a495c5e..d8de073 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -132,6 +132,8 @@ static bool handleEndParBlock(const QCString &, const QCStringList &); static bool handleParam(const QCString &, const QCStringList &); static bool handleRetval(const QCString &, const QCStringList &); +static const char *stateToString(int state); + typedef bool (*DocCmdFunc)(const QCString &name, const QCStringList &optList); struct DocCmdMap @@ -3278,3 +3280,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "commentscan.l.h" diff --git a/src/configimpl.l b/src/configimpl.l index 2d91e12..eaf6cf4 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -43,6 +43,8 @@ #define YY_NO_INPUT 1 #define YY_NO_UNISTD_H 1 +static const char *stateToString(int state); + static const char *warning_str = "warning: "; static const char *error_str = "error: "; @@ -1882,3 +1884,4 @@ void Config::deinit() ConfigImpl::instance()->deleteInstance(); } +#include "configimpl.l.h" diff --git a/src/constexp.l b/src/constexp.l index c9b984a..b6b3c5c 100644 --- a/src/constexp.l +++ b/src/constexp.l @@ -32,6 +32,7 @@ #define YY_NO_UNISTD_H 1 +static const char *stateToString(int state); static int yyread(char *buf,int max_size,yyscan_t yyscanner); #undef YY_INPUT @@ -139,3 +140,4 @@ bool parseconstexp(const char *fileName,int lineNr,const QCString &s) extern "C" { int constexpYYwrap(yyscan_t yyscanner) { return 1; } } +#include "constexp.l.h" diff --git a/src/declinfo.l b/src/declinfo.l index 36ef94a..0ac1516 100644 --- a/src/declinfo.l +++ b/src/declinfo.l @@ -63,6 +63,7 @@ struct declinfoYY_state bool insidePHP; }; +static const char *stateToString(int state); static void addType(yyscan_t yyscanner); static void addTypeName(yyscan_t yyscanner); static int yyread(char *buf,int max_size, yyscan_t yyscanner); @@ -391,3 +392,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "declinfo.l.h" diff --git a/src/defargs.l b/src/defargs.l index 37d904f..070103a 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -87,6 +87,7 @@ static int g_lastDocChar; static int g_lastExtendsContext; static QCString g_delimiter; +static const char *stateToString(int state); /* ----------------------------------------------------------------- */ #undef YY_INPUT @@ -637,3 +638,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "defargs.l.h" diff --git a/src/doctokenizer.l b/src/doctokenizer.l index 6c02bcf..fdc6968 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -76,6 +76,7 @@ struct DocLexerContext static QStack<DocLexerContext> g_lexerStack; +static const char *stateToString(int state); //-------------------------------------------------------------------------- void doctokenizerYYpushContext() @@ -1615,3 +1616,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "doctokenizer.l.h" diff --git a/src/fortrancode.l b/src/fortrancode.l index 38188ef..eee4d47 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -166,6 +166,8 @@ static int inTypeDecl = 0; static bool g_endComment; +static const char *stateToString(int state); + static void endFontClass() { if (g_currentFontClass) @@ -1405,3 +1407,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "fortrancode.l.h" diff --git a/src/fortranscanner.l b/src/fortranscanner.l index 09c4490..38abb89 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -2882,47 +2882,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif -#define scanStateToString(x) case x: resultString = #x; break; -static const char *stateToString(int state) -{ - const char *resultString; - switch(state) - { - scanStateToString(INITIAL) - scanStateToString(Subprog) - scanStateToString(SubprogPrefix) - scanStateToString(Parameterlist) - scanStateToString(SubprogBody) - scanStateToString(SubprogBodyContains) - scanStateToString(Start) - scanStateToString(Comment) - scanStateToString(Module) - scanStateToString(Program) - scanStateToString(ModuleBody) - scanStateToString(ModuleBodyContains) - scanStateToString(AttributeList) - scanStateToString(Variable) - scanStateToString(Initialization) - scanStateToString(ArrayInitializer) - scanStateToString(Enum) - scanStateToString(Typedef) - scanStateToString(TypedefBody) - scanStateToString(TypedefBodyContains) - scanStateToString(InterfaceBody) - scanStateToString(StrIgnore) - scanStateToString(String) - scanStateToString(Use) - scanStateToString(UseOnly) - scanStateToString(ModuleProcedure) - scanStateToString(Prepass) - scanStateToString(DocBlock) - scanStateToString(DocBackLine) - scanStateToString(EndDoc) - scanStateToString(BlockData) - scanStateToString(Prototype) - scanStateToString(PrototypeSubprog) - scanStateToString(PrototypeArgs) - default: resultString = "Unknown"; break; - } - return resultString; -} +#include "fortranscanner.l.h" @@ -62,6 +62,8 @@ //#define DBG_CTX(x) fprintf x #define DBG_CTX(x) do { } while(0) +static const char *stateToString(int state); + struct CondCtx { CondCtx(int line,QCString id,bool b) @@ -3337,3 +3339,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "pre.l.h" diff --git a/src/pycode.l b/src/pycode.l index 0f04baa..a76129d 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -97,6 +97,7 @@ static bool g_endComment; static void endFontClass(); static void adjustScopesAndSuites(unsigned indentLength); +static const char *stateToString(int state); /*! Represents a stack of variable to class mappings as found in the @@ -1646,3 +1647,4 @@ extern "C" { // some bogus code to keep the compiler happy #error "You seem to be using a version of flex newer than 2.5.4. These are currently incompatible with 2.5.4, and do NOT work with doxygen! Please use version 2.5.4 or expect things to be parsed wrongly! A bug report has been submitted (#732132)." #endif +#include "pycode.l.h" diff --git a/src/pyscanner.l b/src/pyscanner.l index 3fe66f2..2320bca 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -123,6 +123,7 @@ static int g_search_count = 0; static QCString g_argType = ""; static bool g_funcParamsEnd; //----------------------------------------------------------------------------- +static const char *stateToString(int state); static void initParser() @@ -1994,3 +1995,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "pyscanner.l.h" diff --git a/src/scan_states.py b/src/scan_states.py new file mode 100644 index 0000000..7f69fdd --- /dev/null +++ b/src/scan_states.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# python script to generate an overview of the staes based on the input lex file. +# +# Copyright (C) 1997-2019 by Dimitri van Heesch. +# +# Permission to use, copy, modify, and distribute this software and its +# documentation under the terms of the GNU General Public License is hereby +# granted. No representations are made about the suitability of this software +# for any purpose. It is provided "as is" without express or implied warranty. +# See the GNU General Public License for more details. +# +# Documents produced by Doxygen are derivative works derived from the +# input used in their production; they are not affected by this license. +# +import sys +import os +import re + + +def main(): + if len(sys.argv)!=2: + sys.exit('Usage: %s <lex_file>' % sys.argv[0]) + + lex_file = sys.argv[1] + if (os.path.exists(lex_file)): + #write preamble + print("#define scanStateToString(x) case x: resultString = #x; break;"); + print("static const char *stateToString(int state)"); + print("{"); + print(" const char *resultString;"); + print(" switch(state)"); + print(" {"); + print(" scanStateToString(INITIAL)"); + + with open(lex_file) as f: + for line in f: + if re.search(r'^%x', line) or re.search(r'^%s', line): + print(" scanStateToString(%s)"%line.split()[1]); + elif re.search(r'^%%', line): + break + else: + pass + f.close() + #write post + print(" default: resultString = \"Unknown\"; break;") + print(" }") + print(" return resultString;") + print("}") + + + +if __name__ == '__main__': + main() diff --git a/src/scanner.l b/src/scanner.l index 75786ef..f6ffdff 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -193,6 +193,7 @@ static int g_column; static int g_fencedSize=0; static bool g_nestedComment=0; +static const char *stateToString(int state); //----------------------------------------------------------------------------- // forward declarations @@ -7490,3 +7491,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "scanner.l.h" diff --git a/src/sqlcode.l b/src/sqlcode.l index eec9732..2685c46 100644 --- a/src/sqlcode.l +++ b/src/sqlcode.l @@ -63,6 +63,7 @@ struct sqlcodeYY_state }; static void codify(const char* text); +static const char *stateToString(int state); static void setCurrentDoc(const QCString &anchor,yyscan_t yyscanner); static void startCodeLine(yyscan_t yyscanner); static void endFontClass(yyscan_t yyscanner); @@ -461,3 +462,4 @@ extern "C" { // some bogus code to keep the compiler happy #error "You seem to be using a version of flex newer than 2.5.4. These are currently incompatible with 2.5.4, and do NOT work with doxygen! Please use version 2.5.4 or expect things to be parsed wrongly! A bug report has been submitted (#732132)." #endif +#include "sqlcode.l.h" diff --git a/src/tclscanner.l b/src/tclscanner.l index 88bd474..a680cf9 100644 --- a/src/tclscanner.l +++ b/src/tclscanner.l @@ -59,6 +59,8 @@ #define MAX_INCLUDE_DEPTH 10 +static const char *stateToString(int state); + //! Application error. #define tcl_err \ printf("Error %d %s() at line %d! ",__LINE__,tcl.file_name.data(),yylineno); \ @@ -3121,3 +3123,4 @@ extern "C" { // some bogus code to keep the compiler happy } #endif +#include "tclscanner.l.h" diff --git a/src/vhdlcode.l b/src/vhdlcode.l index 5f668c6..03bf883 100644 --- a/src/vhdlcode.l +++ b/src/vhdlcode.l @@ -112,6 +112,7 @@ static bool writeColoredWord(QCString& word ); static void generateClassOrGlobalLink(CodeOutputInterface &ol,const char *clName, bool typeOnly=FALSE, const char *curr_class=0); static void endFontClass(); static void startFontClass(const char *s); +static const char *stateToString(int state); //------------------------------------------------------------------- @@ -1646,6 +1647,5 @@ extern "C" { // some bogus code to keep the compiler happy #error "You seem to be using a version of flex newer than 2.5.4 but older than 2.5.33. These versions do NOT work with doxygen! Please use version <=2.5.4 or >=2.5.33 or expect things to be parsed wrongly!" #endif - - +#include "vhdlcode.l.h" diff --git a/src/xmlcode.l b/src/xmlcode.l index 42218b1..bd6e8a8 100644 --- a/src/xmlcode.l +++ b/src/xmlcode.l @@ -69,6 +69,8 @@ static MemberDef * g_currentMemberDef; static bool g_includeCodeFragment; static const char * g_currentFontClass; +static const char *stateToString(int state); + static void codify(const char* text) { g_code->codify(text); @@ -413,3 +415,4 @@ extern "C" { // some bogus code to keep the compiler happy #error "You seem to be using a version of flex newer than 2.5.4. These are currently incompatible with 2.5.4, and do NOT work with doxygen! Please use version 2.5.4 or expect things to be parsed wrongly! A bug report has been submitted (#732132)." #endif +#include "xmlcode.l.h" |