diff --git a/src/ndspkg/compiler/functions.nim b/src/ndspkg/compiler/functions.nim index 0c80b9d..eddcf4b 100644 --- a/src/ndspkg/compiler/functions.nim +++ b/src/ndspkg/compiler/functions.nim @@ -146,4 +146,4 @@ proc parseFunct*(comp: Compiler) = comp.writeChunk(0, upval.index.toDU8()) comp.writeChunk(0, if upval.isLocal: 0'u8 else: 1'u8) -tkFunct.genRule(parseFunct, nop, pcNone) +tkProc.genRule(parseFunct, nop, pcNone) diff --git a/src/ndspkg/compiler/statement.nim b/src/ndspkg/compiler/statement.nim index fb5b5ac..f89a00d 100644 --- a/src/ndspkg/compiler/statement.nim +++ b/src/ndspkg/compiler/statement.nim @@ -47,9 +47,9 @@ proc statement*(comp: Compiler) = if comp.match(tkVar): comp.varStatement() comp.consume(tkSemicolon, "Semicolon expected after expression statement.") - elif comp.match(tkDef): - comp.procStatement() - comp.consume(tkSemicolon, "Semicolon expected after procedure declaration.") +# elif comp.match(tkDef): +# comp.procStatement() +# comp.consume(tkSemicolon, "Semicolon expected after procedure declaration.") elif comp.match(tkBreak): comp.breakStatement() else: diff --git a/src/ndspkg/compiler/utils.nim b/src/ndspkg/compiler/utils.nim index f159417..f8b211b 100644 --- a/src/ndspkg/compiler/utils.nim +++ b/src/ndspkg/compiler/utils.nim @@ -53,7 +53,7 @@ proc synchronize*(comp: Compiler) = while comp.current.tokenType != tkEof: if comp.previous.tokenType in {tkSemicolon, tkRightBrace}: return - if comp.current.tokenType in {tkFunct, tkVar, tkFor, tkIf, tkWhile}: + if comp.current.tokenType in {tkProc, tkVar, tkFor, tkIf, tkWhile}: return comp.advance() diff --git a/src/ndspkg/compv2/parser.nim b/src/ndspkg/compv2/parser.nim index 23d8563..b2b7d65 100644 --- a/src/ndspkg/compv2/parser.nim +++ b/src/ndspkg/compv2/parser.nim @@ -2,7 +2,6 @@ # parser: converts a stream of tokens into an AST import ../scanner -import ../chunk import node import ../config import ../types/value @@ -10,8 +9,6 @@ import ../types/value import strformat import strutils import bitops -import sequtils -import sugar import options # TYPEDEF @@ -55,9 +52,6 @@ proc errorAt(parser: Parser, line: int, msg: string, at: string = "") = parser.hadError = true parser.panicMode = true -proc error(parser: Parser, msg: string) = - parser.errorAt(parser.previous.get().line, msg) - proc errorAtCurrent(parser: Parser, msg: string) = parser.errorAt(parser.current.line, msg) diff --git a/src/ndspkg/config.nim b/src/ndspkg/config.nim index dbdb0be..e913bc5 100644 --- a/src/ndspkg/config.nim +++ b/src/ndspkg/config.nim @@ -17,7 +17,7 @@ const debugClosures* = defined(debug) # specific closure debug switches type compMode* = enum cmOne, cmAst -const compilerChoice* = cmAst +const compilerChoice* = cmOne # choose a compiler: cmOne - version 1, deprecated # cmAst - version 2, but only use parser and print AST produced # cmOne will be removed once compv2 is done diff --git a/tests/collections.nds b/tests/collections.nds index 2dc90ac..6ecd85c 100644 --- a/tests/collections.nds +++ b/tests/collections.nds @@ -13,4 +13,4 @@ print (a[0][0]); a[0][0] = 3; print (a[0][0]); -//expect:3.0; \ No newline at end of file +//expect:3.0 \ No newline at end of file diff --git a/tests/sugar.nds b/tests/sugar.nds index e8a7940..256e26f 100644 --- a/tests/sugar.nds +++ b/tests/sugar.nds @@ -88,14 +88,14 @@ print("finish"); proc() print("merry christmas") :: proc(it) it(); //expect:merry christmas -// proc declaration through def +// proc declaration -def globalProc(a, b, c) +proc globalProc(a, b, c) a + b * c ; { - def localProc(d, e, f) + proc localProc(d, e, f) 2 * d + 3 * e + 4 * f ;