Sha256: b6339507713177b92406baca9d49796858c1a421fcb9d5f43ea27805f2f11434
Contents?: true
Size: 1.19 KB
Versions: 7
Compression:
Stored size: 1.19 KB
Contents
var assert = require("assert"), bnf = require("../../lib/jison/bnf"); json2jison = require("../../lib/jison/json2jison"); exports["test basic grammar"] = function () { var grammar = "%% test: foo bar | baz ; hello: world ;"; var expected = {bnf: {test: ["foo bar", "baz"], hello: ["world"]}}; assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly"); }; exports["test advanced grammar"] = function () { var grammar = "%start foo %% test: foo bar | baz ; hello: world {action} %prec UM;"; var expected = {start: "foo", bnf: {test: ["foo bar", "baz"], hello: [[ "world", "action", {prec: "UM"} ]]}}; assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly"); }; exports["test actions"] = function () { var grammar = "%start foo %% test: foo bar | baz ; hello: world {{action{} }} %prec UM;"; var expected = {start: "foo", bnf: {test: ["foo bar", "baz"], hello: [[ "world", "action{}", {prec: "UM"} ]]}}; assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly"); };
Version data entries
7 entries across 7 versions & 1 rubygems