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 { Compiler } from '../src/compiler/compiler'
|
||||||
import { colors, globals } from '../src/prelude'
|
import { colors, globals } from '../src/prelude'
|
||||||
import { parser } from '../src/parser/shrimp'
|
import { parser } from '../src/parser/shrimp'
|
||||||
|
import { setGlobals } from '../src/parser/tokenizer'
|
||||||
import { treeToString } from '../src/utils/tree'
|
import { treeToString } from '../src/utils/tree'
|
||||||
import { VM, fromValue, bytecodeToString } from 'reefvm'
|
import { VM, fromValue, bytecodeToString } from 'reefvm'
|
||||||
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
||||||
|
|
@ -25,6 +26,7 @@ async function runFile(filePath: string) {
|
||||||
|
|
||||||
async function compileFile(filePath: string) {
|
async function compileFile(filePath: string) {
|
||||||
try {
|
try {
|
||||||
|
setGlobals(Object.keys(globals))
|
||||||
const code = readFileSync(filePath, 'utf-8')
|
const code = readFileSync(filePath, 'utf-8')
|
||||||
const compiler = new Compiler(code)
|
const compiler = new Compiler(code)
|
||||||
return bytecodeToString(compiler.bytecode)
|
return bytecodeToString(compiler.bytecode)
|
||||||
|
|
@ -36,6 +38,7 @@ async function compileFile(filePath: string) {
|
||||||
|
|
||||||
async function parseFile(filePath: string) {
|
async function parseFile(filePath: string) {
|
||||||
try {
|
try {
|
||||||
|
setGlobals(Object.keys(globals))
|
||||||
const code = readFileSync(filePath, 'utf-8')
|
const code = readFileSync(filePath, 'utf-8')
|
||||||
const tree = parser.parse(code)
|
const tree = parser.parse(code)
|
||||||
return treeToString(tree, code)
|
return treeToString(tree, code)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user