UNPKG

apg-js-examples

Version:

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

81 lines (74 loc) 3.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 = 3 // udts = 0 // opcodes = 20 // --- ABNF original opcodes // ALT = 3 // CAT = 2 // REP = 1 // RNM = 3 // TLS = 5 // TBS = 0 // TRG = 5 // --- SABNF superset opcodes // UDT = 0 // AND = 0 // NOT = 0 // BKA = 0 // BKN = 0 // BKR = 1 // ABG = 0 // AEN = 0 // characters = [46 - 122] // ``` /* OBJECT IDENTIFIER (for internal parser use) */ this.grammarObject = 'grammarObject'; /* RULES */ this.rules = []; this.rules[0] = { name: 'HTML', lower: 'html', index: 0, isBkr: false }; this.rules[1] = { name: 'name', lower: 'name', index: 1, isBkr: true }; this.rules[2] = { name: 'alphanum', lower: 'alphanum', index: 2, isBkr: false }; /* UDTS */ this.udts = []; /* OPCODES */ /* HTML */ this.rules[0].opcodes = []; this.rules[0].opcodes[0] = { type: 1, children: [1,9] };// ALT this.rules[0].opcodes[1] = { type: 2, children: [2,3,4,5,6,7,8] };// CAT this.rules[0].opcodes[2] = { type: 7, string: [60] };// TLS this.rules[0].opcodes[3] = { type: 4, index: 1 };// RNM(name) this.rules[0].opcodes[4] = { type: 7, string: [62] };// TLS this.rules[0].opcodes[5] = { type: 4, index: 0 };// RNM(HTML) this.rules[0].opcodes[6] = { type: 7, string: [60,47] };// TLS this.rules[0].opcodes[7] = { type: 14, index: 1, lower: 'name', bkrCase: 603, bkrMode: 602 };// BKR(\%s%pname) this.rules[0].opcodes[8] = { type: 7, string: [62] };// TLS this.rules[0].opcodes[9] = { type: 7, string: [46,46,46] };// TLS /* name */ this.rules[1].opcodes = []; this.rules[1].opcodes[0] = { type: 4, index: 2 };// RNM(alphanum) /* alphanum */ this.rules[2].opcodes = []; this.rules[2].opcodes[0] = { type: 2, children: [1,4] };// CAT this.rules[2].opcodes[1] = { type: 1, children: [2,3] };// ALT this.rules[2].opcodes[2] = { type: 5, min: 97, max: 122 };// TRG this.rules[2].opcodes[3] = { type: 5, min: 65, max: 90 };// TRG this.rules[2].opcodes[4] = { type: 3, min: 0, max: Infinity };// REP this.rules[2].opcodes[5] = { type: 1, children: [6,7,8] };// ALT this.rules[2].opcodes[6] = { type: 5, min: 97, max: 122 };// TRG this.rules[2].opcodes[7] = { type: 5, min: 65, max: 90 };// TRG this.rules[2].opcodes[8] = { type: 5, min: 48, max: 57 };// TRG // The `toString()` function will display the original grammar file(s) that produced these opcodes. this.toString = function toString(){ let str = ""; str += "HTML = \"<\" name \">\" HTML \"</\" \\%s%pname \">\" / \"...\"\n"; str += "name = alphanum\n"; str += "alphanum = (%d97-122/%d65-90) *(%d97-122/%d65-90/%d48-57)\n"; return str; } }