fix #8 ; keep track of source file; display in standard sublime format file:line:col

This commit is contained in:
Timothee Cour 2018-11-29 15:13:25 -08:00
commit 7dd8fff8a7
3 changed files with 6 additions and 1 deletions

View file

@ -239,7 +239,8 @@ proc genNimAst(root: TSNode) =
case $node.tsNodeType(): case $node.tsNodeType():
of "ERROR": of "ERROR":
let (line, col) = getLineCol(node) 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": of "preproc_def":
pPreprocDef(node) pPreprocDef(node)
of "type_definition": of "type_definition":
@ -253,6 +254,7 @@ proc genNimAst(root: TSNode) =
if $node.tsNodeParent.tsNodeType() notin ["type_definition", "declaration"]: if $node.tsNodeParent.tsNodeType() notin ["type_definition", "declaration"]:
pEnumSpecifier(node) pEnumSpecifier(node)
else: else:
# TODO: log
discard discard
else: else:
return return

View file

@ -7,6 +7,7 @@ type
consts*, procs*, types*: seq[string] consts*, procs*, types*: seq[string]
code*, constStr*, currentHeader*, mode*, procStr*, typeStr*: string code*, constStr*, currentHeader*, mode*, procStr*, typeStr*: string
sourceFile*: string # eg, C or C++ source or header file
var var
gStateCT* {.compiletime.}: State gStateCT* {.compiletime.}: State

View file

@ -63,6 +63,8 @@ proc process(path: string) =
defer: defer:
parser.tsParserDelete() parser.tsParserDelete()
gStateRT.sourceFile = path
if gStateRT.mode.len == 0: if gStateRT.mode.len == 0:
gStateRT.mode = modeDefault gStateRT.mode = modeDefault
elif ext in [".h", ".c"]: elif ext in [".h", ".c"]: