nondescript/src/ndspkg/compiler/compiler.nim

28 lines
648 B
Nim

import ../scanner
import ../chunk
import ../config
import types
import utils
# the following modify precedence by being imported
import expressions
import controlflow
import collections
import functions
import statement
proc compile*(comp: Compiler) =
comp.scanner = newScanner(comp.source)
comp.writeChunk(0, opNil)
# the starting stackIndex is 0, which points to this nil
# it is correctly set to delta = 0!!!
comp.advance()
while comp.current.tokenType != tkEof:
comp.statement()
comp.writeChunk(-1, opPop)
comp.writeChunk(0, opReturn)
when debugDumpChunk:
if not comp.hadError:
comp.chunk.disassembleChunk()