Sha256: b68a9eab043677cf79caf4f66fc916121ef84640fb892e0ef12f6cb5263af041

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

/*
 * Classic example grammar, which recognizes simple arithmetic expressions like
 * "2*(3+4)". The parser generated from this grammar then computes their value.
 */

start
  = additive

additive
  = left:multiplicative "+" right:additive { return left + right; }
  / multiplicative

multiplicative
  = left:primary "*" right:multiplicative { return left * right; }
  / primary

primary
  = integer
  / "(" additive:additive ")" { return additive; }

integer "integer"
  = digits:$[0-9]+ { return parseInt(digits, 10); }

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spider-src-0.1.7 lib/spider-src/support/spider/node_modules/pegjs/examples/arithmetics.pegjs
spider-src-0.1.6 lib/spider-src/support/spider/node_modules/spider-script/node_modules/pegjs/examples/arithmetics.pegjs