UNPKG

apg-js-examples

Version:

Examples of using the suite of apg-js applications and libraries.

64 lines (58 loc) 2.15 kB
// copyright: Copyright (c) 2024 Lowell D. Thomas, all rights reserved<br> // license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)<br> // // Generated by apg-js, Version 4.4.0 [apg-js](https://github.com/ldthomas/apg-js) module.exports = function grammar(){ // ``` // SUMMARY // rules = 2 // udts = 0 // opcodes = 8 // --- ABNF original opcodes // ALT = 1 // CAT = 1 // REP = 0 // RNM = 1 // TLS = 2 // TBS = 0 // TRG = 0 // --- SABNF superset opcodes // UDT = 0 // AND = 0 // NOT = 0 // BKA = 0 // BKN = 0 // BKR = 3 // ABG = 0 // AEN = 0 // characters = [120 - 121] // ``` /* OBJECT IDENTIFIER (for internal parser use) */ this.grammarObject = 'grammarObject'; /* RULES */ this.rules = []; this.rules[0] = { name: 'simple', lower: 'simple', index: 0, isBkr: false }; this.rules[1] = { name: 'A', lower: 'a', index: 1, isBkr: true }; /* UDTS */ this.udts = []; /* OPCODES */ /* simple */ this.rules[0].opcodes = []; this.rules[0].opcodes[0] = { type: 2, children: [1,2,3,4] };// CAT this.rules[0].opcodes[1] = { type: 4, index: 1 };// RNM(A) this.rules[0].opcodes[2] = { type: 14, index: 1, lower: 'a', bkrCase: 604, bkrMode: 601 };// BKR(\%i%uA) this.rules[0].opcodes[3] = { type: 14, index: 1, lower: 'a', bkrCase: 604, bkrMode: 601 };// BKR(\%i%uA) this.rules[0].opcodes[4] = { type: 14, index: 1, lower: 'a', bkrCase: 603, bkrMode: 601 };// BKR(\%s%uA) /* A */ this.rules[1].opcodes = []; this.rules[1].opcodes[0] = { type: 1, children: [1,2] };// ALT this.rules[1].opcodes[1] = { type: 7, string: [120] };// TLS this.rules[1].opcodes[2] = { type: 7, string: [121] };// TLS // The `toString()` function will display the original grammar file(s) that produced these opcodes. this.toString = function toString(){ let str = ""; str += "simple = A \\A \\%iA \\%sA\n"; str += "A = \"x\" / \"y\"\n"; return str; } }