@ -70,7 +70,7 @@ var utils = require("../../utils"),
*
*
* [ 11 ] IF _ERROR t , f
* [ 11 ] IF _ERROR t , f
*
*
* if ( stack . top ( ) === null ) {
* if ( stack . top ( ) === FAILED ) {
* interpret ( ip + 3 , ip + 3 + t ) ;
* interpret ( ip + 3 , ip + 3 + t ) ;
* } else {
* } else {
* interpret ( ip + 3 + t , ip + 3 + t + f ) ;
* interpret ( ip + 3 + t , ip + 3 + t + f ) ;
@ -78,7 +78,7 @@ var utils = require("../../utils"),
*
*
* [ 12 ] IF _NOT _ERROR t , f
* [ 12 ] IF _NOT _ERROR t , f
*
*
* if ( stack . top ( ) !== null ) {
* if ( stack . top ( ) !== FAILED ) {
* interpret ( ip + 3 , ip + 3 + t ) ;
* interpret ( ip + 3 , ip + 3 + t ) ;
* } else {
* } else {
* interpret ( ip + 3 + t , ip + 3 + t + f ) ;
* interpret ( ip + 3 + t , ip + 3 + t + f ) ;
@ -86,7 +86,7 @@ var utils = require("../../utils"),
*
*
* [ 13 ] WHILE _NOT _ERROR b
* [ 13 ] WHILE _NOT _ERROR b
*
*
* while ( stack . top ( ) !== null ) {
* while ( stack . top ( ) !== FAILED ) {
* interpret ( ip + 2 , ip + 2 + b ) ;
* interpret ( ip + 2 , ip + 2 + b ) ;
* }
* }
*
*
@ -137,7 +137,7 @@ var utils = require("../../utils"),
*
*
* [ 20 ] FAIL e
* [ 20 ] FAIL e
*
*
* stack . push ( null ) ;
* stack . push ( FAILED ) ;
* fail ( consts [ e ] ) ;
* fail ( consts [ e ] ) ;
*
*
* Calls
* Calls
@ -214,7 +214,7 @@ module.exports = function(ast, options) {
function buildSimplePredicate ( expression , negative , context ) {
function buildSimplePredicate ( expression , negative , context ) {
var emptyStringIndex = addConst ( '""' ) ,
var emptyStringIndex = addConst ( '""' ) ,
nullIndex = addConst ( 'null ') ;
failedIndex = addConst ( 'peg$FAILED ') ;
return buildSequence (
return buildSequence (
[ op . PUSH _CURR _POS ] ,
[ op . PUSH _CURR _POS ] ,
@ -235,7 +235,7 @@ module.exports = function(ast, options) {
buildSequence (
buildSequence (
[ op . POP ] ,
[ op . POP ] ,
[ negative ? op . POP _CURR _POS : op . POP ] ,
[ negative ? op . POP _CURR _POS : op . POP ] ,
[ op . PUSH , null Index]
[ op . PUSH , failed Index]
)
)
)
)
) ;
) ;
@ -244,7 +244,7 @@ module.exports = function(ast, options) {
function buildSemanticPredicate ( code , negative , context ) {
function buildSemanticPredicate ( code , negative , context ) {
var functionIndex = addFunctionConst ( utils . keys ( context . env ) , code ) ,
var functionIndex = addFunctionConst ( utils . keys ( context . env ) , code ) ,
emptyStringIndex = addConst ( '""' ) ,
emptyStringIndex = addConst ( '""' ) ,
nullIndex = addConst ( 'null ') ;
failedIndex = addConst ( 'peg$FAILED ') ;
return buildSequence (
return buildSequence (
[ op . REPORT _CURR _POS ] ,
[ op . REPORT _CURR _POS ] ,
@ -253,11 +253,11 @@ module.exports = function(ast, options) {
[ op . IF ] ,
[ op . IF ] ,
buildSequence (
buildSequence (
[ op . POP ] ,
[ op . POP ] ,
[ op . PUSH , negative ? null Index : emptyStringIndex ]
[ op . PUSH , negative ? failed Index : emptyStringIndex ]
) ,
) ,
buildSequence (
buildSequence (
[ op . POP ] ,
[ op . POP ] ,
[ op . PUSH , negative ? emptyStringIndex : null Index]
[ op . PUSH , negative ? emptyStringIndex : failed Index]
)
)
)
)
) ;
) ;
@ -357,7 +357,7 @@ module.exports = function(ast, options) {
} ,
} ,
sequence : function ( node , context ) {
sequence : function ( node , context ) {
var emptyArrayIndex , nul lIndex;
var emptyArrayIndex , fai lIndex;
function buildElementsCode ( elements , context ) {
function buildElementsCode ( elements , context ) {
var processedCount , functionIndex ;
var processedCount , functionIndex ;
@ -381,7 +381,7 @@ module.exports = function(ast, options) {
buildSequence (
buildSequence (
processedCount > 1 ? [ op . POP _N , processedCount ] : [ op . POP ] ,
processedCount > 1 ? [ op . POP _N , processedCount ] : [ op . POP ] ,
[ op . POP _CURR _POS ] ,
[ op . POP _CURR _POS ] ,
[ op . PUSH , null Index]
[ op . PUSH , failed Index]
)
)
)
)
) ;
) ;
@ -409,7 +409,7 @@ module.exports = function(ast, options) {
}
}
if ( node . elements . length > 0 ) {
if ( node . elements . length > 0 ) {
nullIndex = addConst ( 'null ') ;
failedIndex = addConst ( 'peg$FAILED ') ;
return buildSequence (
return buildSequence (
[ op . PUSH _CURR _POS ] ,
[ op . PUSH _CURR _POS ] ,
@ -500,7 +500,7 @@ module.exports = function(ast, options) {
one _or _more : function ( node , context ) {
one _or _more : function ( node , context ) {
var emptyArrayIndex = addConst ( '[]' ) ;
var emptyArrayIndex = addConst ( '[]' ) ;
nullIndex = addConst ( 'null ') ;
failedIndex = addConst ( 'peg$FAILED ') ;
expressionCode = generate ( node . expression , {
expressionCode = generate ( node . expression , {
sp : context . sp + 1 ,
sp : context . sp + 1 ,
env : { } ,
env : { } ,
@ -513,7 +513,7 @@ module.exports = function(ast, options) {
buildCondition (
buildCondition (
[ op . IF _NOT _ERROR ] ,
[ op . IF _NOT _ERROR ] ,
buildSequence ( buildAppendLoop ( expressionCode ) , [ op . POP ] ) ,
buildSequence ( buildAppendLoop ( expressionCode ) , [ op . POP ] ) ,
buildSequence ( [ op . POP ] , [ op . POP ] , [ op . PUSH , null Index] )
buildSequence ( [ op . POP ] , [ op . POP ] , [ op . PUSH , failed Index] )
)
)
) ;
) ;
} ,
} ,