module.exports = function grammar(){
copyright: Copyright (c) 2023 Lowell D. Thomas, all rights reserved
license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)
Generated by apg-js, Version 4.2.1 apg-js
module.exports = function grammar(){
SUMMARY
rules = 10
udts = 0
opcodes = 31
--- ABNF original opcodes
ALT = 5
CAT = 2
REP = 4
RNM = 11
TLS = 0
TBS = 4
TRG = 5
--- SABNF superset opcodes
UDT = 0
AND = 0
NOT = 0
BKA = 0
BKN = 0
BKR = 0
ABG = 0
AEN = 0
characters = [0 - 4294967295]
/* OBJECT IDENTIFIER (for internal parser use) */
this.grammarObject = 'grammarObject';
/* RULES */
this.rules = [];
this.rules[0] = {name: 'file', lower: 'file', index: 0, isBkr: false};
this.rules[1] = {name: 'line', lower: 'line', index: 1, isBkr: false};
this.rules[2] = {name: 'line-text', lower: 'line-text', index: 2, isBkr: false};
this.rules[3] = {name: 'last-line', lower: 'last-line', index: 3, isBkr: false};
this.rules[4] = {name: 'valid', lower: 'valid', index: 4, isBkr: false};
this.rules[5] = {name: 'invalid', lower: 'invalid', index: 5, isBkr: false};
this.rules[6] = {name: 'end', lower: 'end', index: 6, isBkr: false};
this.rules[7] = {name: 'CRLF', lower: 'crlf', index: 7, isBkr: false};
this.rules[8] = {name: 'LF', lower: 'lf', index: 8, isBkr: false};
this.rules[9] = {name: 'CR', lower: 'cr', index: 9, isBkr: false};
/* UDTS */
this.udts = [];
/* OPCODES */
/* file */
this.rules[0].opcodes = [];
this.rules[0].opcodes[0] = {type: 2, children: [1,3]};// CAT
this.rules[0].opcodes[1] = {type: 3, min: 0, max: Infinity};// REP
this.rules[0].opcodes[2] = {type: 4, index: 1};// RNM(line)
this.rules[0].opcodes[3] = {type: 3, min: 0, max: 1};// REP
this.rules[0].opcodes[4] = {type: 4, index: 3};// RNM(last-line)
/* line */
this.rules[1].opcodes = [];
this.rules[1].opcodes[0] = {type: 2, children: [1,2]};// CAT
this.rules[1].opcodes[1] = {type: 4, index: 2};// RNM(line-text)
this.rules[1].opcodes[2] = {type: 4, index: 6};// RNM(end)
/* line-text */
this.rules[2].opcodes = [];
this.rules[2].opcodes[0] = {type: 3, min: 0, max: Infinity};// REP
this.rules[2].opcodes[1] = {type: 1, children: [2,3]};// ALT
this.rules[2].opcodes[2] = {type: 4, index: 4};// RNM(valid)
this.rules[2].opcodes[3] = {type: 4, index: 5};// RNM(invalid)
/* last-line */
this.rules[3].opcodes = [];
this.rules[3].opcodes[0] = {type: 3, min: 1, max: Infinity};// REP
this.rules[3].opcodes[1] = {type: 1, children: [2,3]};// ALT
this.rules[3].opcodes[2] = {type: 4, index: 4};// RNM(valid)
this.rules[3].opcodes[3] = {type: 4, index: 5};// RNM(invalid)
/* valid */
this.rules[4].opcodes = [];
this.rules[4].opcodes[0] = {type: 1, children: [1,2]};// ALT
this.rules[4].opcodes[1] = {type: 5, min: 32, max: 126};// TRG
this.rules[4].opcodes[2] = {type: 6, string: [9]};// TBS
/* invalid */
this.rules[5].opcodes = [];
this.rules[5].opcodes[0] = {type: 1, children: [1,2,3,4]};// ALT
this.rules[5].opcodes[1] = {type: 5, min: 0, max: 8};// TRG
this.rules[5].opcodes[2] = {type: 5, min: 11, max: 12};// TRG
this.rules[5].opcodes[3] = {type: 5, min: 14, max: 31};// TRG
this.rules[5].opcodes[4] = {type: 5, min: 127, max: 4294967295};// TRG
/* end */
this.rules[6].opcodes = [];
this.rules[6].opcodes[0] = {type: 1, children: [1,2,3]};// ALT
this.rules[6].opcodes[1] = {type: 4, index: 7};// RNM(CRLF)
this.rules[6].opcodes[2] = {type: 4, index: 8};// RNM(LF)
this.rules[6].opcodes[3] = {type: 4, index: 9};// RNM(CR)
/* CRLF */
this.rules[7].opcodes = [];
this.rules[7].opcodes[0] = {type: 6, string: [13,10]};// TBS
/* LF */
this.rules[8].opcodes = [];
this.rules[8].opcodes[0] = {type: 6, string: [10]};// TBS
/* CR */
this.rules[9].opcodes = [];
this.rules[9].opcodes[0] = {type: 6, string: [13]};// TBS
The toString()
function will display the original grammar file(s) that produced these opcodes.
this.toString = function toString(){
let str = "";
str += "file = *line [last-line]\n";
str += "line = line-text end\n";
str += "line-text = *(valid/invalid)\n";
str += "last-line = 1*(valid/invalid)\n";
str += "valid = %d32-126 / %d9\n";
str += "invalid = %d0-8 / %d11-12 /%d14-31 / %x7f-ffffffff\n";
str += "end = CRLF / LF / CR\n";
str += "CRLF = %d13.10\n";
str += "LF = %d10\n";
str += "CR = %d13\n";
return str;
}
}