Browse Source

Read input program from file

master
Forest Belton 2 years ago
parent
commit
c21a41e9b0
4 changed files with 30 additions and 17 deletions
  1. +3
    -0
      example.gby
  2. +11
    -5
      lib/main.ts
  3. +15
    -12
      package-lock.json
  4. +1
    -0
      package.json

+ 3
- 0
example.gby View File

@ -0,0 +1,3 @@
u8 x;
x <- 1;

+ 11
- 5
lib/main.ts View File

@ -1,9 +1,15 @@
import { promises } from "fs"
import { compile } from "./compile"
const output = compile(`
u8 x;
const { readFile } = promises
x <- 1;
`)
if (process.argv.length !== 3) {
console.error("usage: gbuoy <program.b>")
process.exit(1)
}
console.log(output)
const fileName = process.argv[2]
readFile(fileName, { encoding: "utf-8" }).then(source => {
const output = compile(source)
console.log(output)
})

+ 15
- 12
package-lock.json View File

@ -8,14 +8,21 @@
"name": "gbuoy",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"systemjs": "^6.10.3"
"bin": {
"gbuoy": "gbuoy.js"
},
"devDependencies": {
"@types/node": "^16.9.1",
"peggy": "^1.2.0",
"typescript": "^4.4.3"
}
},
"node_modules/@types/node": {
"version": "16.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz",
"integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
"dev": true
},
"node_modules/peggy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/peggy/-/peggy-1.2.0.tgz",
@ -28,11 +35,6 @@
"node": ">=10"
}
},
"node_modules/systemjs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.10.3.tgz",
"integrity": "sha512-mXwfLJdaADqWg1J5+Z0bGQEdcXSe+ePPTfzffMB29aVls5cXveRl0vneSV/19t3SfuUBsAraLP8W/g5u9cmYXA=="
},
"node_modules/typescript": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
@ -48,17 +50,18 @@
}
},
"dependencies": {
"@types/node": {
"version": "16.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz",
"integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
"dev": true
},
"peggy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/peggy/-/peggy-1.2.0.tgz",
"integrity": "sha512-PQ+NKpAobImfMprYQtc4Egmyi29bidRGEX0kKjCU5uuW09s0Cthwqhfy7mLkwcB4VcgacE5L/ZjruD/kOPCUUw==",
"dev": true
},
"systemjs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.10.3.tgz",
"integrity": "sha512-mXwfLJdaADqWg1J5+Z0bGQEdcXSe+ePPTfzffMB29aVls5cXveRl0vneSV/19t3SfuUBsAraLP8W/g5u9cmYXA=="
},
"typescript": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",

+ 1
- 0
package.json View File

@ -1,5 +1,6 @@
{
"devDependencies": {
"@types/node": "^16.9.1",
"peggy": "^1.2.0",
"typescript": "^4.4.3"
},

Loading…
Cancel
Save