From 7dd8fff8a7cf518cbc663b72598477b622ae1822 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 29 Nov 2018 15:13:25 -0800 Subject: [PATCH] fix #8 ; keep track of source file; display in standard sublime format file:line:col --- nimterop/ast.nim | 4 +++- nimterop/globals.nim | 1 + toast.nim | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nimterop/ast.nim b/nimterop/ast.nim index fe0111f..069ecba 100644 --- a/nimterop/ast.nim +++ b/nimterop/ast.nim @@ -239,7 +239,8 @@ proc genNimAst(root: TSNode) = case $node.tsNodeType(): of "ERROR": let (line, col) = getLineCol(node) - echo &"Potentially invalid syntax at line {line} column {col}" + let file = gStateRT.sourceFile + echo &"# [toast] Potentially invalid syntax at {file}:{line}:{col}" of "preproc_def": pPreprocDef(node) of "type_definition": @@ -253,6 +254,7 @@ proc genNimAst(root: TSNode) = if $node.tsNodeParent.tsNodeType() notin ["type_definition", "declaration"]: pEnumSpecifier(node) else: + # TODO: log discard else: return diff --git a/nimterop/globals.nim b/nimterop/globals.nim index 1e3a83c..f1ba151 100644 --- a/nimterop/globals.nim +++ b/nimterop/globals.nim @@ -7,6 +7,7 @@ type consts*, procs*, types*: seq[string] code*, constStr*, currentHeader*, mode*, procStr*, typeStr*: string + sourceFile*: string # eg, C or C++ source or header file var gStateCT* {.compiletime.}: State diff --git a/toast.nim b/toast.nim index b418308..f743264 100644 --- a/toast.nim +++ b/toast.nim @@ -63,6 +63,8 @@ proc process(path: string) = defer: parser.tsParserDelete() + gStateRT.sourceFile = path + if gStateRT.mode.len == 0: gStateRT.mode = modeDefault elif ext in [".h", ".c"]: