Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from outercloudstudio/dev
Browse files Browse the repository at this point in the history
fix: More reliable compiler and more compiler errors v1.0.1
  • Loading branch information
outercloudstudio committed Feb 5, 2022
2 parents 4354584 + 2a5adfd commit 5101abb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
4 changes: 4 additions & 0 deletions ExecutionTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function buildCodeBlocks(tokens){
if(tokens[x][y].value == '}' && tokens[x][y].token == 'SYMBOL'){
let openPath = openPaths.pop()

if(!openPath){
return new Backend.Error('Unexpected }!')
}

let inBlockLines = []

for(let i = openPath.x; i <= x; i++){
Expand Down
61 changes: 39 additions & 22 deletions Firework.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as Backend from './Backend.js'
import chalk from 'chalk'
import { createSpinner } from 'nanospinner'

//D:\.MCAddons\projects\Firework Testing

function CompileFile(source, path, endPath, config){
//console.log('Compiling entity from ' + source + ' to ' + endPath + ' with ' + path)

Expand Down Expand Up @@ -48,7 +50,7 @@ export async function Start(path, com){
const spinner = createSpinner('Waiting for bridge to compile...').start()

while(!fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP') || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json')){
await(sleep(1000))
await sleep(1000)
}

spinner.success()
Expand All @@ -59,18 +61,18 @@ export async function Start(path, com){
await sleep(100)

while(!fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP') || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json')){
await(sleep(100))
await sleep(100)
}

try{
//try{
let mainfest = null

while(!mainfest || !fs.existsSync(com + '/development_behavior_packs/' + projectName + ' BP/entities/')){
try{
mainfest = JSON.parse(fs.readFileSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json'))
}catch{}

await(sleep(100))
await sleep(100)
}

if(!mainfest.firework || forced){
Expand Down Expand Up @@ -116,29 +118,44 @@ export async function Start(path, com){
}
}

searchFolderForEntity(com + '/development_behavior_packs/' + projectName + ' BP/entities')

searchFolderForEntity(path + '/BP/entities')
for(let i = 0; i < files.length; i++){
const targetFileName = files[i].substring(0, files[i].length - 5) + '.frw'
const targetFilePath = com + '/development_behavior_packs/' + projectName + ' BP/firework/' + fileRelPaths[i] + targetFileName
const sourceFilePath = com + '/development_behavior_packs/' + projectName + ' BP/entities/' + fileRelPaths[i] + files[i]
const projectSourceFilePath = path + '/BP/firework/' + fileRelPaths[i] + targetFileName

if(fs.existsSync(sourceFilePath)){
if(fs.existsSync(targetFilePath)){
const result = CompileFile(sourceFilePath, targetFilePath, com + '/development_behavior_packs/' + projectName + ' BP', JSON.parse(fs.readFileSync(path + '/.firework/config.json')))
if(!fs.existsSync(projectSourceFilePath)){
console.log(chalk.hex('#ffc825').bold('Warning:') + ' Skipping ' + files[i])

if(result instanceof Backend.Error){
console.log(chalk.hex('#ea323c').bold('Error:') + ' ' + result.message)
continue
}

break
}else{
console.log(chalk.hex('#5ac54f').bold(`Compiled ${targetFileName}!`))
}
}else{
//console.log(chalk.hex('#ffc825').bold('Warning:') + ' Could not find file for ' + targetFileName)
}
const spinner = createSpinner('Waiting for source of ' + files[i] + '...').start()

while(!fs.existsSync(sourceFilePath)){
await sleep(100)
}

spinner.success()

const spinner2 = createSpinner('Waiting for target of ' + targetFileName + '...').start()

while(!fs.existsSync(targetFilePath)){
await sleep(100)
}

spinner2.success()

const result = CompileFile(sourceFilePath, targetFilePath, com + '/development_behavior_packs/' + projectName + ' BP', JSON.parse(fs.readFileSync(path + '/.firework/config.json')))

if(result instanceof Backend.Error){
console.log(chalk.hex('#ea323c').bold('Error:') + ' ' + result.message)

break
}else{
//console.log(chalk.hex('#ffc825').bold('Warning:') + ' Could not find file for ' + files[i])
console.log(chalk.hex('#5ac54f').bold(`Compiled ${targetFileName}!`))
}
}

Expand All @@ -151,8 +168,8 @@ export async function Start(path, com){

fs.writeFileSync(com + '/development_behavior_packs/' + projectName + ' BP/manifest.json', JSON.stringify(mainfest, null, 2))
}
}catch (err){
console.log(chalk.hex('#ffc825').bold('Warning:') + ' Ignored error: ' + err.toString())
}
//}catch (err){
// console.log(chalk.hex('#ffc825').bold('Warning:') + ' Ignored error: ' + err.toString())
//}
}
}

0 comments on commit 5101abb

Please sign in to comment.