Test for number of parens
This commit is contained in:
parent
938a9d22ec
commit
3093a74d57
@ -46,6 +46,10 @@ function Commander (ronin) {
|
||||
this.reindent = function () {
|
||||
let val = this._input.value.replace(/\n/g, '').replace(/ +(?= )/g, '').replace(/\( \(/g, '((').replace(/\) \)/g, '))').trim()
|
||||
let depth = 0
|
||||
if (val.split('(').length !== val.split(')').length) {
|
||||
ronin.log('Uneven number of parens.')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
const c = val.charAt(i)
|
||||
if (c === '(') { depth++ } else if (c === ')') { depth-- }
|
||||
|
@ -153,7 +153,7 @@ function Lisp (lib = {}, includes = []) {
|
||||
}
|
||||
|
||||
const tokenize = function (input) {
|
||||
const i = input.replace(/^\;.*\n?/gm, '').replace('λ','lambda ').split('"')
|
||||
const i = input.replace(/^\;.*\n?/gm, '').replace('λ', 'lambda ').split('"')
|
||||
return i.map(function (x, i) {
|
||||
return i % 2 === 0
|
||||
? x.replace(/\(/g, ' ( ')
|
||||
|
Loading…
x
Reference in New Issue
Block a user