-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cxx: add a function for decoding CXXTokenType
For making CXX_DO_DEBUGGING debug output more readable, cxxDebugTypeDecode is introduced. cxxDebugTypeDecode takes enum CXXTokenType typed parameter and returns its C string representation. It can be used in CXX_DEBUG_PRINT. misc/gencxxtypedumper.sh generates cxxDebugTypeDecode function from enum CXXTokenType definition in cxx_token.h. misc/gencxxtypedumper.sh is not integrated with ctags building scripts because the script itself requires ctags internally. Generated source code (cxx_debug_type.c) is committed to our git repository. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
- Loading branch information
Showing
8 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
# | ||
# gencxxtypedumper - Generating cxxDebugTypeDecode function | ||
# | ||
# Copyright (C) 2014 Masatake YAMATO | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
INPUT=./parsers/cxx/cxx_token.h | ||
CTAGS=./ctags | ||
OUTPUT=./parsers/cxx/cxx_debug_type.c | ||
|
||
exec > ${OUTPUT} | ||
echo '/* Automatically generated by misc/gencxxtypedumper.sh */' | ||
echo | ||
echo '#include "cxx_token.h"' | ||
echo '#include "cxx_debug.h"' | ||
echo | ||
echo '#ifdef CXX_DO_DEBUGGING' | ||
echo 'const char * cxxDebugTypeDecode (enum CXXTokenType eType)' | ||
echo '{' | ||
echo ' switch (eType) {' | ||
${CTAGS} -o - --language-force=C --kinds-C=e -x --_xformat="%N" "${INPUT}" \ | ||
| grep ^CXXTokenType \ | ||
| while read N; do | ||
echo " case $N: return \"${N#CXXTokenType}\";" | ||
done | ||
echo ' default: return "REALLY-UNKNOWN";' | ||
echo ' }' | ||
echo '}' | ||
echo '#endif' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Automatically generated by misc/gencxxtypedumper.sh */ | ||
|
||
#include "cxx_token.h" | ||
#include "cxx_debug.h" | ||
|
||
#ifdef CXX_DO_DEBUGGING | ||
const char * cxxDebugTypeDecode (enum CXXTokenType eType) | ||
{ | ||
switch (eType) { | ||
case CXXTokenTypeAnd: return "And"; | ||
case CXXTokenTypeAngleBracketChain: return "AngleBracketChain"; | ||
case CXXTokenTypeAssignment: return "Assignment"; | ||
case CXXTokenTypeBracketChain: return "BracketChain"; | ||
case CXXTokenTypeCharacterConstant: return "CharacterConstant"; | ||
case CXXTokenTypeClosingBracket: return "ClosingBracket"; | ||
case CXXTokenTypeClosingParenthesis: return "ClosingParenthesis"; | ||
case CXXTokenTypeClosingSquareParenthesis: return "ClosingSquareParenthesis"; | ||
case CXXTokenTypeComma: return "Comma"; | ||
case CXXTokenTypeDotOperator: return "DotOperator"; | ||
case CXXTokenTypeEOF: return "EOF"; | ||
case CXXTokenTypeGreaterThanSign: return "GreaterThanSign"; | ||
case CXXTokenTypeIdentifier: return "Identifier"; | ||
case CXXTokenTypeKeyword: return "Keyword"; | ||
case CXXTokenTypeMultipleAnds: return "MultipleAnds"; | ||
case CXXTokenTypeMultipleColons: return "MultipleColons"; | ||
case CXXTokenTypeMultipleDots: return "MultipleDots"; | ||
case CXXTokenTypeNumber: return "Number"; | ||
case CXXTokenTypeOpeningBracket: return "OpeningBracket"; | ||
case CXXTokenTypeOpeningParenthesis: return "OpeningParenthesis"; | ||
case CXXTokenTypeOpeningSquareParenthesis: return "OpeningSquareParenthesis"; | ||
case CXXTokenTypeOperator: return "Operator"; | ||
case CXXTokenTypeParenthesisChain: return "ParenthesisChain"; | ||
case CXXTokenTypePointerOperator: return "PointerOperator"; | ||
case CXXTokenTypeSemicolon: return "Semicolon"; | ||
case CXXTokenTypeSingleColon: return "SingleColon"; | ||
case CXXTokenTypeSmallerThanSign: return "SmallerThanSign"; | ||
case CXXTokenTypeSquareParenthesisChain: return "SquareParenthesisChain"; | ||
case CXXTokenTypeStar: return "Star"; | ||
case CXXTokenTypeStringConstant: return "StringConstant"; | ||
case CXXTokenTypeUnknown: return "Unknown"; | ||
default: return "REALLY-UNKNOWN"; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters