Skip to content

Commit

Permalink
Merge pull request #3681 from masatake/misc-fix
Browse files Browse the repository at this point in the history
Misc fix
  • Loading branch information
masatake committed Mar 28, 2023
2 parents 8a4f1ae + 4e11202 commit 95f44c5
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ The following parsers have been added:
* Elm *peg/packcc*
* Falcon
* FrontMatter *only YAML syntax, running as a guest on R?Markdown*
* FunctionParameters *perl based subparser*
* FunctionParameters *Perl based subparser*
* Gdbinit script *optlib*
* GemSpec *Ruby based subparser*
* GDScript
Expand All @@ -423,7 +423,7 @@ The following parsers have been added:
* GPerf *optlib*
* Haskell
* Haxe
* iPythonCell *optlib*, *pthon based subparser*
* iPythonCell *optlib*, *Python based subparser*
* Inko *optlib*
* JavaProperties
* JSON
Expand All @@ -437,7 +437,7 @@ The following parsers have been added:
* Maven2 *libxml*
* MesonBuild (Meson) *optlib*
* MesonOptions *optlib+script*
* Moose *perl based subparser*
* Moose *Perl based subparser*
* Myrddin
* M4
* NSIS
Expand Down
13 changes: 13 additions & 0 deletions main/dependency.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,16 @@ extern void subparserColprintTablePrint (struct colprintTable *table,
colprintTableSort (table, subparserColprintCompareLines);
colprintTablePrint (table, 0, withListHeader, machinable, fp);
}

extern const char *dependencyTypeString(enum eDepType e)
{ /* Generated by misc/enumstr.sh with cmdline:
misc/enumstr.sh main/dependency.h eDepType dependencyTypeString DEPTYPE_ */
switch (e)
{
case DEPTYPE_KIND_OWNER: return "KIND_OWNER";
case DEPTYPE_SUBPARSER: return "SUBPARSER";
case DEPTYPE_FOREIGNER: return "FOREIGNER";
case COUNT_DEPTYPES: return "COUNT_DEPTYPES";
default: return "UNKNOWN";
}
}
1 change: 1 addition & 0 deletions main/dependency_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ extern void finalizeDependencies (parserDefinition *parser,
extern slaveParser *getFirstSlaveParser(struct slaveControlBlock *controlBlock);
extern slaveParser *getNextSlaveParser(slaveParser *last);

extern const char *dependencyTypeString(enum eDepType e);
#endif /* CTAGS_MAIN_DEPENDENCY_PRIVATE_H */
3 changes: 3 additions & 0 deletions main/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,9 @@ static void linkDependenciesAtInitializeParsing (parserDefinition *const parser)

upperParser = LanguageTable + upper;

verbose ("link dependencies: type = %s, upper = %s, lower = %s\n",
dependencyTypeString(d->type),
upperParser->def->name, lowerParser->name);
linkDependencyAtInitializeParsing (d->type, upperParser->def,
upperParser->slaveControlBlock,
upperParser->kindControlBlock,
Expand Down
64 changes: 50 additions & 14 deletions misc/enumstr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,58 @@ ENUM_NAME=$2
FUNNAME=$3
shift 3

if [ "$1" = "--use-lower-bits-as-is" ]; then
PREFIX_FOR_TRIMMING=
USE_LOWER_BITS_AS_IS=$1
shift 1
else
PREFIX_FOR_TRIMMING=$1
shift 1
if [ "$1" = "--use-lower-bits-as-is" ]; then
USE_LOWER_BITS_AS_IS=$1
shift 1
else
USE_LOWER_BITS_AS_IS=
fi
print_usage()
{
echo Usage:
echo
echo " $0 <input-file> <enum-name> <funname> [PREFIX_FOR_TRIMMING] [OPTIONS]"
echo " $0 --help|-h"
echo
echo Options:
echo
echo " --use-lower-bits-as-is"
echo " --extern"
echo
echo Example:
echo
echo ' $ bash ./misc/enumstr.sh parsers/jscript.c eTokenType tokenTypeName'
exit $1
}

if [ -z "$INPUT_FILE" ] || [ -z "$ENUM_NAME" ] || [ -z "$FUNNAME" ] || \
[ "$INPUT_FILE" = '-h' ] || [ "$ENUM_NAME" = '-h' ] || [ "$FUNNAME" = '-h' ] || \
[ "$INPUT_FILE" = '--help' ] || [ "$ENUM_NAME" = '--help' ] || [ "$FUNNAME" = '--help' ]; then
print_usage 1 1>&2
fi

echo 'static const char *'"$FUNAME"'(enum '$ENUM_NAME' e)'
USE_LOWER_BITS_AS_IS=
SCOPE='static'

while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
print_usage 0
;;
--use-lower-bits-as-is)
USE_LOWER_BITS_AS_IS=$1
shift 1
;;
--extern)
SCOPE=extern
shift 1
;;
-*)
echo "Unknown option: $1" 1>&2
exit 1
;;
*)
PREFIX_FOR_TRIMMING=$1
shift 1
;;
esac
done

printf '%s const char *'"%s"'(enum '%s' e)\n' "$SCOPE" "$FUNNAME" "$ENUM_NAME"
printf '{ /* Generated by misc/enumstr.sh with cmdline:\n'
echo " $0 $INPUT_FILE $ENUM_NAME $FUNNAME $PREFIX_FOR_TRIMMING $USE_LOWER_BITS_AS_IS */"
echo ' switch (e)'
Expand Down
4 changes: 2 additions & 2 deletions misc/review
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ units_inspect_cmd_show_generic ()
if [[ -r "$f" ]]; then
"$@" "$f"
else
echo "No ${file}" 1>&2
echo "No $f" 1>&2
fi
echo '---'
echo '# ' "$f"
Expand Down Expand Up @@ -197,7 +197,7 @@ units_inspect_show_expected_tags ()
(
shopt -s extglob
units_inspect_cmd_show_generic $tcase $(basename ./Units/${tcase}/expected.tags?\(-*\)) "cat" "-n"
units_inspect_cmd_show_generic $tcase $(basename ./Units/${tcase}/expected.tags?(-*)) "cat" "-n"
)
}
shopt -u extglob
Expand Down

0 comments on commit 95f44c5

Please sign in to comment.