Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
500 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"plugins": [ | ||
"babel-plugin-transform-class-properties", | ||
"babel-plugin-add-module-exports" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- NOTE: If you have a PROPOSAL, then | ||
this does not apply to you. | ||
In that case, include a clear | ||
definiton, a formal grammar for | ||
your proposal, examples, and why | ||
that feature would be helpful. | ||
--> | ||
|
||
**Version:** the version you're runnning. Found through `cheddar -V` | ||
|
||
### Problem | ||
|
||
Describe what exactly the problem you've found is. | ||
Try not to just specify your particular instance. | ||
Additionally, attempt to be as detailed as possible. | ||
|
||
### Desired Behavior | ||
|
||
### How to Reproduce | ||
|
||
1. Do ... | ||
2. Then do ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
dist | ||
coverage | ||
coverage | ||
update | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
default: | ||
babel --minify | ||
build: | ||
babel | ||
install: | ||
./bin/install | ||
test: | ||
./node_modules/.bin/mocha --reporter spec | ||
|
||
babel-node ./node_modules/.bin/babel-istanbul cover _mocha | ||
clean: | ||
rm -rf ./dist/ | ||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
#!/usr/bin/env node | ||
|
||
const pjson = require('../../package.json'); | ||
const program = require('commander'); | ||
const child_process = require('child_process'); | ||
const tty = require('tty'); | ||
const fs = require('fs'); | ||
|
||
/*== Handle REPL Seperately ==*/ | ||
if (!process.argv[2]) { | ||
child_process.fork(__dirname + (tty.isatty(0) ? '/repl.js' : '/prog.js')); | ||
} | ||
if (!module.parent) { | ||
/*== Handle REPL Seperately ==*/ | ||
if (!process.argv[2]) { | ||
child_process.fork(__dirname + (tty.isatty(0) ? '/repl.js' : '/prog.js')); | ||
} | ||
|
||
program | ||
.version(pjson.version) | ||
.usage('[files ...] [options]') | ||
.option('-e, --eval [code]', 'executes code, passed inline. implicit return') | ||
.option('-E, --exec [code]', 'executes code, passed inline') | ||
.option('-f, --file [path]', 'executes file') | ||
.option('-i, --repl', 'Enters repl') | ||
.parse(process.argv); | ||
program | ||
.version(pjson.version) | ||
.usage('[files ...] [options]') | ||
.option('-e, --eval [code]', 'executes code, passed inline. implicit return') | ||
.option('-E, --exec [code]', 'executes code, passed inline') | ||
.option('-f, --file [path]', 'executes file') | ||
.option('-i, --repl', 'Enters repl') | ||
.parse(process.argv); | ||
|
||
program.args.forEach(file => child_process.exec( | ||
`${__dirname}/prog.js < ${file}` | ||
)); | ||
program.args.forEach(file => child_process.exec( | ||
`${__dirname}/prog.js < ${file}` | ||
)); | ||
} else { | ||
module.exports = require('./prog'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,49 @@ | ||
#!/usr/bin/env node | ||
|
||
import CheddarScope from '../interpreter/core/env/scope'; | ||
|
||
import cheddar from '../interpreter/exec'; | ||
import tokenizer from '../tokenizer/tok'; | ||
|
||
let GLOBAL_SCOPE = new CheddarScope(); | ||
import dep_String from '../interpreter/core/primitives/String'; | ||
import dep_Bool from '../interpreter/core/primitives/Bool'; | ||
import dep_Number from '../interpreter/core/primitives/Number'; | ||
import dep_Array from '../interpreter/core/primitives/Array'; | ||
|
||
import CheddarVariable from '../interpreter/core/env/var'; | ||
|
||
const CONSTANT = { Writeable: false }; | ||
let GLOBAL_SCOPE = new CheddarScope(null, new Map([ | ||
["String" , new CheddarVariable(dep_String, CONSTANT)], | ||
["Number" , new CheddarVariable(dep_Number, CONSTANT)], | ||
["Array" , new CheddarVariable(dep_Array , CONSTANT)], | ||
["Boolean", new CheddarVariable(dep_Bool , CONSTANT)] | ||
])); | ||
|
||
let STDIN = ""; | ||
let chunk; | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.on('readable', () => { | ||
chunk = process.stdin.read(); | ||
if (chunk !== null) | ||
STDIN += chunk; | ||
}); | ||
process.stdin.on('end', () => { | ||
let Tokenizer = new tokenizer(STDIN, 0); | ||
let Result = Tokenizer.exec(); | ||
if (!module.parent) { | ||
let STDIN = ""; | ||
let chunk; | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.on('readable', () => { | ||
chunk = process.stdin.read(); | ||
if (chunk !== null) | ||
STDIN += chunk; | ||
}); | ||
process.stdin.on('end', () => { | ||
let Tokenizer = new tokenizer(STDIN, 0); | ||
let Result = Tokenizer.exec(); | ||
|
||
let Executor = new cheddar(Result, GLOBAL_SCOPE); | ||
Executor.exec(); | ||
}); | ||
let Executor = new cheddar(Result, GLOBAL_SCOPE); | ||
Executor.exec(); | ||
}); | ||
} else { | ||
module.exports = function(code, done, scope) { | ||
let Tokenizer = new tokenizer(code, 0); | ||
let Result = Tokenizer.exec(); | ||
|
||
let Executor = new cheddar(Result, scope || GLOBAL_SCOPE); | ||
Executor.exec(); | ||
|
||
if (done) done(Executor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print "1+1=" + String::(1+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"string"; | ||
'string'; | ||
123; | ||
123.456; | ||
0b101; | ||
0o777; | ||
0xFF; | ||
true; | ||
false; | ||
[1,2,3]; | ||
[1, 2, 3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var chai = require('chai'); | ||
|
||
chai.should(); | ||
|
||
var someFunction = (a, b) => a + b; | ||
|
||
describe('something', () => { | ||
it ('should do something', () => { | ||
someFunction(3, 2).should.equal(5); | ||
}) | ||
it ('should test stdout', function(){ | ||
it('tests', function(done) { | ||
proc.stdout.once('data', function(output) { | ||
expect(output.toString('utf-8')).to.eq('Would you like to play?\n'); | ||
done(); | ||
}); | ||
}); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var chai = require('chai'); | ||
|
||
chai.should(); | ||
|
||
// the .es6 files won't work, because they use import which node doesn't support. that's why we have babel-node, it means the code coverage shows the lines on the ES6 files too | ||
// oh, okay, currently the `make test` doesn't use babel-node I don't think, should I just add `babel-node` to the beginning | ||
// thouguh, but babel-node still have to compile a lot of stuff (almost all of cheddar) | ||
// in which case idk if we should recompile | ||
// tests should be called before you commit to origin, not necessarily every ten minutes. I wouldn't worry about speed | ||
// ;_; okay | ||
import CheddarString from '../../../src/interpreter/core/primitives/String.es6'; | ||
import CheddarNumber from '../../../src/interpreter/core/primitives/Number.es6'; | ||
import CheddarArray from '../../../src/interpreter/core/primitives/Array.es6' ; | ||
import CheddarBool from '../../../src/interpreter/core/primitives/Bool.es6' ; | ||
|
||
var result = new Map([ | ||
['String', CheddarString], | ||
['Number', CheddarNumber], | ||
['Array' , CheddarArray ], | ||
['Bool' , CheddarBool ], | ||
]); | ||
|
||
var Alias = require('../../../src/interpreter/core/config/alias.es6'); | ||
|
||
describe('alias config', () => { | ||
it ('should provide a correct result', () => { | ||
Alias.should.deep.equal(result); | ||
}) | ||
}) |
Oops, something went wrong.