shrimp cli wants the prelude too
This commit is contained in:
parent
68ec6f9f3e
commit
4258503c0e
|
|
@ -3,6 +3,7 @@
|
|||
import { Compiler } from '../src/compiler/compiler'
|
||||
import { colors, globals } from '../src/prelude'
|
||||
import { parser } from '../src/parser/shrimp'
|
||||
import { setGlobals } from '../src/parser/tokenizer'
|
||||
import { treeToString } from '../src/utils/tree'
|
||||
import { VM, fromValue, bytecodeToString } from 'reefvm'
|
||||
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
||||
|
|
@ -25,6 +26,7 @@ async function runFile(filePath: string) {
|
|||
|
||||
async function compileFile(filePath: string) {
|
||||
try {
|
||||
setGlobals(Object.keys(globals))
|
||||
const code = readFileSync(filePath, 'utf-8')
|
||||
const compiler = new Compiler(code)
|
||||
return bytecodeToString(compiler.bytecode)
|
||||
|
|
@ -36,6 +38,7 @@ async function compileFile(filePath: string) {
|
|||
|
||||
async function parseFile(filePath: string) {
|
||||
try {
|
||||
setGlobals(Object.keys(globals))
|
||||
const code = readFileSync(filePath, 'utf-8')
|
||||
const tree = parser.parse(code)
|
||||
return treeToString(tree, code)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user