update compv1, remove def from compv1
This commit is contained in:
parent
8d1e9a5318
commit
c36292843a
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,4 +13,4 @@ print (a[0][0]);
|
|||
|
||||
a[0][0] = 3;
|
||||
print (a[0][0]);
|
||||
//expect:3.0;
|
||||
//expect:3.0
|
|
@ -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
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in New Issue