Skip to content

Commit

Permalink
Merge pull request #8 from wikimedia/pegjs0.9
Browse files Browse the repository at this point in the history
Pegjs0.9
  • Loading branch information
Marko Obrovac committed Oct 26, 2015
2 parents e333ceb + 93cae49 commit 184d119
Show file tree
Hide file tree
Showing 7 changed files with 2,027 additions and 1,999 deletions.
6 changes: 0 additions & 6 deletions lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

var typecheck = module.exports.typecheck = function(val, type, self) {
switch (type) {
case 'any':
return true;
case 'string':
return typeof(val) === type;
case 'self':
Expand Down Expand Up @@ -158,10 +156,6 @@ var Tex = module.exports.Tex = new Enum( 'Tex', {
FUN2nb: { args: [ 'string', 'self', 'self' ] },
INFIX: { args: [ 'string', ['self'], ['self'] ] },
FUN2sq: { args: [ 'string', 'self', 'self' ] },
FUN1hl: { args: [ 'string', 'any', 'self' ] },
FUN1hf: { args: [ 'string', FontForce, 'self' ] },
FUN2h: { args: [ 'string', 'any', 'self', 'self' ] },
INFIXh: { args: [ 'string', 'any', [ 'self' ], [ 'self' ] ] },
MATRIX: { args: [ 'string', [ [ [ 'self' ] ] ] ] },
DECLh: { args: [ 'string', FontForce, [ 'self' ] ] }
});
Expand Down
19 changes: 0 additions & 19 deletions lib/astutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ ast.Tex.defineVisitor("contains_func", {
// \f{a} (function of one argument, "no braces" around outside)
return match(target, f) || a.contains_func(target);
},
FUN1hl: function(target, f, _, a) {
// \f{a} ... this is not currently generated by the parser
return match(target, f) || a.contains_func(target);
},
FUN1hf: function(target, f, _, a) {
// \f{a} ... this is not currently generated by the parser
return match(target, f) || a.contains_func(target);
},
DECLh: function(target, f, _, a) {
// {\rm a1 a2 a3 a4 ...} where f is \rm, \it, \cal, or \bf
return match(target, f) || arr_contains_func(a, target);
Expand All @@ -128,11 +120,6 @@ ast.Tex.defineVisitor("contains_func", {
return match(target, f) ||
a.contains_func(target) || b.contains_func(target);
},
FUN2h: function(target, f, _, a, b) {
// \f{a}{b} ... this is not currently generated by the parser
return match(target, f) ||
a.contains_func(target) || b.contains_func(target);
},
FUN2nb: function(target, f, a, b) {
// \f{a}{b} (function of two arguments, "no braces" around outside)
return match(target, f) ||
Expand All @@ -152,12 +139,6 @@ ast.Tex.defineVisitor("contains_func", {
return match(target, s) ||
arr_contains_func(ll, target) || arr_contains_func(rl, target);
},
INFIXh: function(target, s, _, ll, rl) {
// { ll1 ll2 ... \s rl1 rl2 ... } (infix function)
// ... this is not currently generated by the parser
return match(target, s) ||
arr_contains_func(ll, target) || arr_contains_func(rl, target);
},
BOX: function(target, box, s) {
// \box{s} where box is \text, \mbox, \hbox, or \vbox
// and s is a string not containing special characters
Expand Down
8 changes: 4 additions & 4 deletions lib/build-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ var buildParser = module.exports = function(inFile, outFile) {
});
// hack up the source to make it pass jshint
parserSource = parserSource
.replace(/peg\$subclass\(child, parent\) {/g, function(m) {
return m + "\n /*jshint validthis:true, newcap:false */";
}).replace(/\n(\s+)([?:+]) (expectedDescs|" or ")/g, ' $2\n$1$3');
.replace(/(peg\$subclass\(child, parent\)|peg\$SyntaxError\(message, expected, found, location\)|peg\$parse\(input\)) {/g,
function (m) {
return m + "\n /*jshint validthis:true, newcap:false*/ ";
}).replace(/\n(\s+)([?:+]) (expectedDescs|" or "|peg)/g, ' $2\n$1$3');
parserSource =
'/* jshint latedef: nofunc */\n' +
'"use strict";\n' +
'module.exports = ' + parserSource + ';';

fs.writeFileSync(outFile, parserSource, 'utf8');
Expand Down
Loading

0 comments on commit 184d119

Please sign in to comment.