Drop SCAN_TRACING

This commit is contained in:
K. Lange 2022-08-14 13:52:59 +09:00
parent 13d018986a
commit 9732e0115a
6 changed files with 7 additions and 52 deletions

View File

@ -68,10 +68,6 @@ ifdef KRK_NO_TRACING
CFLAGS += -DKRK_NO_TRACING=1
endif
ifdef KRK_NO_SCAN_TRACING
CFLAGS += -DKRK_NO_SCAN_TRACING=1
endif
ifdef KRK_NO_STRESS_GC
CFLAGS += -DKRK_NO_STRESS_GC=1
endif
@ -83,7 +79,6 @@ help:
@echo " KRK_NO_... Compile without support for debugging features..."
@echo " DISASSEMBLY=1 Do not enable disassembly at compile time."
@echo " TRACING=1 Do not enable runtime tracing."
@echo " SCAN_TRACING=1 Do not enable lexer debugging."
@echo " STRESS_GC=1 Do not enable eager GC stress testing."
@echo " KRK_DISABLE_THREADS=1 Disable threads on platforms that otherwise support them."
@echo " KRK_DISABLE_RLINE=1 Do not build with the rich line editing library enabled."

View File

@ -39,8 +39,6 @@ Valid flags to pass to `krk_initVM()` include:
Prints instruction traces during execution.
- `KRK_THREAD_ENABLE_DISASSEMBLY`
Prints function bytecode disassembly whenever the compiler is called.
- `KRK_THREAD_ENABLE_SCAN_TRACING`
Prints token stream data whenever the compiler is called. (Not recommended.)
- `KRK_THREAD_SINGLE_STEP`
Halts execution and calls the debugger before every instruction.
- `KRK_GLOBAL_REPORT_GC_COLLECTS`

View File

@ -122,9 +122,6 @@ typedef void (*ParseInfixFn)(struct GlobalState *, int, struct RewindState *);
* are for the infix parsing.
*/
typedef struct {
#ifndef KRK_NO_SCAN_TRACING
const char * name; /**< Stringified token name for error messages and debugging. */
#endif
ParsePrefixFn prefix; /**< Parse function to call when this token appears at the start of an expression. */
ParseInfixFn infix; /**< Parse function to call when this token appears after an expression. */
Precedence precedence; /**< Precedence ordering for Pratt parsing, @ref Precedence */
@ -455,18 +452,6 @@ static void _advance(struct GlobalState * state) {
if (state->parser.eatingWhitespace &&
(state->parser.current.type == TOKEN_INDENTATION || state->parser.current.type == TOKEN_EOL)) continue;
#ifndef KRK_NO_SCAN_TRACING
if (krk_currentThread.flags & KRK_THREAD_ENABLE_SCAN_TRACING) {
fprintf(stderr, " [%s<%d> %d:%d '%.*s']\n",
getRule(state->parser.current.type)->name,
(int)state->parser.current.type,
(int)state->parser.current.line,
(int)state->parser.current.col,
(int)state->parser.current.length,
state->parser.current.start);
}
#endif
if (state->parser.current.type == TOKEN_RETRY) continue;
if (state->parser.current.type != TOKEN_ERROR) break;
@ -1335,13 +1320,6 @@ static void block(struct GlobalState * state, size_t indentation, const char * b
}
if (state->parser.hadError) skipToEnd();
};
#ifndef KRK_NO_SCAN_TRACING
if (krk_currentThread.flags & KRK_THREAD_ENABLE_SCAN_TRACING) {
fprintf(stderr, "\n\nfinished with block %s (ind=%d) on line %d, sitting on a %s (len=%d)\n\n",
blockName, (int)indentation, (int)state->parser.current.line,
getRule(state->parser.current.type)->name, (int)state->parser.current.length);
}
#endif
}
} else {
statement(state);
@ -1694,9 +1672,6 @@ static KrkToken classDeclaration(struct GlobalState * state) {
advance(); /* Pass the indentation */
classBody(state, currentIndentation);
}
#ifndef KRK_NO_SCAN_TRACING
if (krk_currentThread.flags & KRK_THREAD_ENABLE_SCAN_TRACING) fprintf(stderr, "Exiting from class definition on %s\n", getRule(state->parser.current.type)->name);
#endif
/* Exit from block */
}
} /* else empty class (and at end of file?) we'll allow it for now... */
@ -3796,11 +3771,7 @@ KrkCodeObject * krk_compile(const char * src, char * fileName) {
return function;
}
#ifdef KRK_NO_SCAN_TRACING
# define RULE(token, a, b, c) [TOKEN_ ## token] = {a, b, c}
#else
# define RULE(token, a, b, c) [TOKEN_ ## token] = {# token, a, b, c}
#endif
#define RULE(token, a, b, c) [TOKEN_ ## token] = {a, b, c}
/**
* @brief Parse rules table.

View File

@ -765,7 +765,7 @@ int main(int argc, char * argv[]) {
int inspectAfter = 0;
int opt;
int maxDepth = -1;
while ((opt = getopt(argc, argv, "+:c:C:dgGim:rR:stTMSV-:")) != -1) {
while ((opt = getopt(argc, argv, "+:c:C:dgGim:rR:tTMSV-:")) != -1) {
switch (opt) {
case 'c':
runCmd = optarg;
@ -781,10 +781,6 @@ int main(int argc, char * argv[]) {
case 'G':
flags |= KRK_GLOBAL_REPORT_GC_COLLECTS;
break;
case 's':
/* Print debug information during compilation. */
flags |= KRK_THREAD_ENABLE_SCAN_TRACING;
break;
case 'S':
flags |= KRK_THREAD_SINGLE_STEP;
break;
@ -841,7 +837,6 @@ int main(int argc, char * argv[]) {
" -m mod Run a module as a script.\n"
" -r Disable complex line editing in the REPL.\n"
" -R depth Set maximum recursion depth.\n"
" -s Debug output from the scanner/tokenizer.\n"
" -t Disassemble instructions as they are exceuted.\n"
" -T Write call trace file.\n"
" -C file Compile 'file', but do not execute it.\n"

View File

@ -212,7 +212,7 @@ typedef struct KrkVM {
/* Thread-specific flags */
#define KRK_THREAD_ENABLE_TRACING (1 << 0)
#define KRK_THREAD_ENABLE_DISASSEMBLY (1 << 1)
#define KRK_THREAD_ENABLE_SCAN_TRACING (1 << 2)
/* reserved, formerly SCAN_TRACING */
#define KRK_THREAD_HAS_EXCEPTION (1 << 3)
#define KRK_THREAD_SINGLE_STEP (1 << 4)
#define KRK_THREAD_SIGNALLED (1 << 5)

View File

@ -32,18 +32,16 @@
KRK_Function(set_tracing) {
int tracing = -1;
int disassembly = -1;
int scantracing = -1;
if (!krk_parseArgs(
"|$ppp", (const char *[]){"tracing","disassembly","scantracing"},
&tracing, &disassembly, &scantracing)) {
"|$pp", (const char *[]){"tracing","disassembly"},
&tracing, &disassembly)) {
return NONE_VAL();
}
#define SET_THREAD(arg,flag) do { if (arg != -1) { if (arg) krk_currentThread.flags |= KRK_THREAD_ENABLE_ ## flag; else krk_currentThread.flags &= ~KRK_THREAD_ENABLE_ ## flag; } } while (0)
SET_THREAD(tracing,TRACING);
SET_THREAD(disassembly,DISASSEMBLY);
SET_THREAD(scantracing,SCAN_TRACING);
#undef SET_THREAD
return BOOLEAN_VAL(1);
@ -213,12 +211,10 @@ void krk_module_init_kuroko(void) {
"@param clean Whether to remove escapes.");
KRK_DOC(BIND_FUNC(vm.system,set_tracing),
"@brief Toggle debugging modes.\n"
"@arguments tracing=None,disassembly=None,scantracing=None,stressgc=None\n\n"
"@arguments tracing=None,disassembly=None\n\n"
"Enables or disables tracing options for the current thread.\n\n"
"@param tracing Enables instruction tracing.\n"
"@param disassembly Prints bytecode disassembly after compilation.\n"
"@param scantracing Prints debug output from the token scanner during compilation.\n"
"@param stressgc Forces a garbage collection cycle on each heap allocation.");
"@param disassembly Prints bytecode disassembly after compilation.");
KRK_DOC(BIND_FUNC(vm.system,importmodule),
"@brief Import a module by string name\n"
"@arguments module\n\n"