Implemented basic macro expand functionality (#20579)
* Implemented level based macro expand functionality - it can handle single macro call or expand whole function/proc/etc and it - In addition, I have altered the parser to provide the endInfo for the node. The usefulness of the `endInfo` is not limited to the `expandMacro` functionality but also it is useful for `ideOutline` functionality and I have altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of the time is lost during the AST transformation thus in `nimsuggest.nim` I am using freshly parsed tree to get the location information. * Make sure we stop expanding correctly * Test CI * Fix tv3_outline.nim
This commit is contained in:
parent
4647c7b596
commit
7031ea65cd
13 changed files with 345 additions and 60 deletions
|
|
@ -66,7 +66,7 @@ proc parseTest(filename: string; epcMode=false): Test =
|
|||
elif x.startsWith(">"):
|
||||
# since 'markers' here are not complete yet, we do the $substitutions
|
||||
# afterwards
|
||||
result.script.add((x.substr(1).replaceWord("$path", tpath), ""))
|
||||
result.script.add((x.substr(1).replaceWord("$path", tpath).replaceWord("$file", filename), ""))
|
||||
elif x.len > 0:
|
||||
# expected output line:
|
||||
let x = x % ["file", filename, "lib", libpath]
|
||||
|
|
@ -218,7 +218,12 @@ proc sexpToAnswer(s: SexpNode): string =
|
|||
result.add doc
|
||||
result.add '\t'
|
||||
result.addInt a[8].getNum
|
||||
if a.len >= 10:
|
||||
if a.len >= 11:
|
||||
result.add '\t'
|
||||
result.addInt a[9].getNum
|
||||
result.add '\t'
|
||||
result.addInt a[10].getNum
|
||||
elif a.len >= 10:
|
||||
result.add '\t'
|
||||
result.add a[9].getStr
|
||||
result.add '\L'
|
||||
|
|
@ -229,8 +234,8 @@ proc doReport(filename, answer, resp: string; report: var string) =
|
|||
var hasDiff = false
|
||||
for i in 0..min(resp.len-1, answer.len-1):
|
||||
if resp[i] != answer[i]:
|
||||
report.add "\n Expected: " & resp.substr(i, i+200)
|
||||
report.add "\n But got: " & answer.substr(i, i+200)
|
||||
report.add "\n Expected:\n" & resp
|
||||
report.add "\n But got:\n" & answer
|
||||
hasDiff = true
|
||||
break
|
||||
if not hasDiff:
|
||||
|
|
@ -342,8 +347,8 @@ proc main() =
|
|||
if os.paramCount() > 0:
|
||||
let x = os.paramStr(1)
|
||||
let xx = expandFilename x
|
||||
# run only stdio when running single test
|
||||
failures += runTest(xx)
|
||||
failures += runEpcTest(xx)
|
||||
else:
|
||||
let files = toSeq(walkFiles(tpath / "t*.nim"))
|
||||
for i, x in files:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue