@yinyinfurong_zmr/dbc-can
Version:
A general purpose CAN (Controller Area Network) toolbox with support for .dbc file parsing, CAN message decoding, and more
1,201 lines (1,199 loc) • 163 kB
JavaScript
'use strict';
function table2Enum(table) {
const regEx = /(?<value>[0-9-]+) "(?<description>(?:[^"\\]|\\.)*)"/gi;
const matches = table.matchAll(regEx);
const definitions = new Map();
for (const match of matches) {
if (match.groups) {
definitions.set(parseInt(match.groups.value, 10), match.groups.description);
}
}
return definitions;
}
function cleanComment(comment) {
const noSemiColon = comment.replace(';', '');
const final = noSemiColon.replace(/"/gi, '');
return final.trim();
}
function extractAttrType(str) {
const match = str.match(/BO_|BU_|SG_|EV_/);
if (match) {
switch (match === null || match === void 0 ? void 0 : match.toString()) {
case 'BO_':
return 'Message';
case 'BU_':
return 'Node';
case 'SG_':
return 'Signal';
case 'EV_':
return 'EnvironmentVariable';
default:
return 'Global';
}
}
else {
return 'Global';
}
}
function extractAttrNode(type, str) {
let matches;
switch (type) {
case 'Message':
return '';
case 'Signal':
return '';
case 'Node':
matches = str.match(/BU_\s(?<node>[a-zA-Z0-9_]+)\s(?<value>.*)\s*;/);
if (matches) {
if (matches.groups) {
return matches.groups.node;
}
}
case 'Global':
return '';
case 'EnvironmentVariable':
matches = str.match(/EV_\s(?<node>[a-zA-Z0-9_]+)\s(?<value>.*)\s*;/);
if (matches) {
if (matches.groups) {
return matches.groups.node;
}
}
default:
return '';
}
}
function extractAttrVal(type, str) {
let matches;
switch (type) {
case 'Message':
matches = str.match(/BO_\s(?<id>[0-9]+)\s(?<value>.*);/);
if (matches) {
if (matches.groups) {
return cleanComment(matches.groups.value);
}
}
case 'Signal':
matches = str.match(/SG_\s(?<id>[0-9]+)\s(?<signalName>[a-zA-Z0-9_]+)\s(?<value>.*);/);
if (matches) {
if (matches.groups) {
return cleanComment(matches.groups.value);
}
}
case 'Node':
matches = str.match(/BU_\s(?<node>[a-zA-Z0-9_]+)\s(?<value>.*)\s*;/);
if (matches) {
if (matches.groups) {
return cleanComment(matches.groups.value);
}
}
case 'Global':
matches = str.match(/(?<value>.*)\s*;/);
if (matches) {
if (matches.groups) {
return cleanComment(matches.groups.value);
}
}
case 'EnvironmentVariable':
matches = str.match(/EV_\s(?<node>[a-zA-Z0-9_]+)\s(?<value>.*)\s*;/);
if (matches) {
if (matches.groups) {
return cleanComment(matches.groups.value);
}
}
default:
return '';
}
}
function extractAttrSignalName(type, str) {
let matches;
let signalName = '';
switch (type) {
case 'Message':
break;
case 'Signal':
matches = str.match(/SG_\s(?<id>[0-9]+)\s(?<signalName>[a-zA-Z0-9_]+)\s(?<value>.*);/);
if (matches) {
if (matches.groups) {
signalName = matches.groups.signalName;
}
}
break;
}
return signalName;
}
function extractAttrId(type, str) {
let matches;
switch (type) {
case 'Message':
matches = str.match(/BO_\s(?<id>[0-9]+)\s(?<value>.*);/);
if (matches) {
if (matches.groups) {
return matches.groups.id;
}
}
case 'Signal':
matches = str.match(/SG_\s(?<id>[0-9]+)\s(?<signalName>[a-zA-Z0-9_]+)\s(?<value>.*);/);
if (matches) {
if (matches.groups) {
return matches.groups.id;
}
}
case 'Node':
return '';
case 'Global':
return '';
default:
return '';
}
}
function extractMinVal(type, str) {
let min = 0;
switch (type) {
case 'FLOAT':
const floatMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (floatMatches && floatMatches.groups) {
min = parseFloat(floatMatches.groups.min);
}
break;
case 'STRING':
break;
case 'HEX':
const hexMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (hexMatches && hexMatches.groups) {
min = parseFloat(hexMatches.groups.min);
}
break;
case 'ENUM':
break;
case 'INT':
const intMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (intMatches && intMatches.groups) {
min = parseFloat(intMatches.groups.min);
}
break;
}
return min;
}
function extractMaxVal(type, str) {
let max = 0;
switch (type) {
case 'FLOAT':
const floatMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (floatMatches && floatMatches.groups) {
max = parseFloat(floatMatches.groups.max);
}
break;
case 'STRING':
break;
case 'HEX':
const hexMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (hexMatches && hexMatches.groups) {
max = parseFloat(hexMatches.groups.max);
}
break;
case 'ENUM':
break;
case 'INT':
const intMatches = str.match(/\s*(?<min>[0-9.]+)\s(?<max>[0-9.]+)\s*;/);
if (intMatches && intMatches.groups) {
max = parseFloat(intMatches.groups.max);
}
break;
}
return max;
}
function extractOptions(type, str) {
if (type !== 'ENUM') {
return [];
}
const newStr = str.replace(';', '');
const strArr = newStr.split(',');
const final = strArr.map((s) => {
return s.replace(/"/gi, '').trim();
});
return final;
}
/* AutoGenerated Code, changes may be overwritten
* INPUT GRAMMAR:
* ---
* import { table2Enum, cleanComment, extractAttrType,
* extractAttrNode, extractAttrVal, extractAttrId, extractMinVal,
* extractMaxVal, extractOptions, extractAttrSignalName } from "./parserHelpers";
* ---
* Choice := CanNode | CanMessage | SignalMultiplexVal | CanSignal | ValTable | Val | SignalComment | MessageComment | NodeComment |
* GlobalAttribute | MessageAttribute | SignalAttribute | NodeAttribute | AttributeDefault | AttributeValue |
* Version | NewSymbolValue | BlankLine | NewSymbol | BusSpeed | Comment | CanEnvironmentVariable | EnvironmentVarData |
* EnvironmentVariableComment | MessageTransmitter | EnvironmentAttribute | EnvironmentVal | CanSignalGroup | SigValType
* BlankLine := ''$
* CanSignalGroup := 'SIG_GROUP_\s+' raw_id={'[0-9]+'} '\s+' name={'[a-zA-Z0-9_]+'} '\s+' raw_group_number={'[0-9]+'} '\s+:\s*' raw_signal_string={'[a-zA-Z0-9_\s]*'} '\s*'
* .signals = string[] { return raw_signal_string.replace(';', '').split(' '); }
* .id = number {return parseInt(raw_id,10);}
* .group_number = number {return parseInt(raw_group_number,10);}
* MessageTransmitter := 'BO_TX_BU_\s+' raw_id={'[0-9]+'} '\s*:\s*' raw_nodes = {'.*'}
* .id = number {return parseInt(raw_id,10);}
* .nodes = string[] {return raw_nodes.replace(';', '').split(',');}
* CanEnvironmentVariable := 'EV_\s+' name={'[a-zA-Z0-9_]+'} '\s*:\s*' type={'0|1|2'} '\s+\[' raw_min={'[\-0-9.]+'} '\|' raw_max={'[\-0-9.]+'} '\]\s' raw_unit={'".*"'} '\s+' raw_inital_value={'[\-0-9.]+'} '\s+' raw_ev_id={'[0-9]+'} '\s+' access_type={'[a-zA-Z0-9_]+'} '\s+' node={'[a-zA-Z0-9_]+'}
* .min = number {return parseFloat(raw_min);}
* .max = number {return parseFloat(raw_max);}
* .unit = string {return cleanComment(raw_unit);}
* .initial_value = number {return parseFloat(raw_inital_value);}
* .ev_id = number {return parseInt(raw_ev_id,10);}
* EnvironmentVarData := 'ENVVAR_DATA_\s+' name={'[a-zA-Z0-9_]+'} '\s*:\s*' raw_value={'[0-9]+'}
* .value = number {return parseInt(raw_value);}
* EnvironmentVariableComment := 'CM_ EV_\s+' name={'[a-zA-Z0-9_]+'} '\s' raw_comment={'.*'}
* .comment = string {return cleanComment(raw_comment);}
* Version := 'VERSION' '\s+' raw_version={'.*'}
* .version = string {return cleanComment(raw_version);}
* NewSymbol := 'NS_\s*:'
* BusSpeed := 'BS_:'
* NewSymbolValue := '\s+' symbol={'[a-zA-Z_]+_'} '$'?
* CanNode := 'BU_:\s*' raw_node_string={'[a-zA-Z0-9_\s]*'} '\s*' ';'?
* .node_names = string[] { return raw_node_string.split(' '); }
* CanMessage := 'BO_\s' raw_id={'[0-9]+'} '\s*' name={'[a-zA-Z0-9_]*'} ':\s*' raw_dlc={'[0-9]'} '\s*' node={'[a-zA-Z0-9_]*'}
* .id = number {return parseInt(raw_id,10);}
* .dlc = number {return parseInt(raw_dlc,10);}
* CanSignal := '\s*SG_\s' name={'[a-zA-Z0-9_]+'} '\s*' multiplex={'M|[m0-9M]*|\s'} '\s*:\s' raw_start_bit={'[0-9]+'} '\|' raw_length={'[0-9]+'} '@' raw_endian={'[1|0]'} raw_signed={'[+|-]'} '\s\(' raw_factor={'[\-0-9.]+'} ',' raw_offset={'[\-0-9.]+'} '\)\s\[' raw_min={'[\-0-9.]+'} '\|' raw_max={'[\-0-9.]+'} '\]\s' raw_unit={'".*"'} '\s' raw_node_str={'.*'}
* .multiplexer = boolean {return multiplex.includes('M');}
* .unit = string {return cleanComment(raw_unit);}
* .nodes = string[] {return raw_node_str.trim().split(',');}
* .start_bit = number {return parseInt(raw_start_bit,10);}
* .length = number {return parseInt(raw_length,10);}
* .endian = string {return raw_endian === '1' ? 'Intel' : 'Motorola'}
* .signed = boolean {return raw_signed === '-' ? true : false;}
* .factor = number {return parseFloat(raw_factor);}
* .offset = number {return parseFloat(raw_offset);}
* .min = number {return parseFloat(raw_min);}
* .max = number {return parseFloat(raw_max);}
* SignalMultiplexVal := 'SG_MUL_VAL_\s' raw_id={'[0-9]+'} '\s*' name={'[a-zA-Z0-9_]+'} '\s*' switch_name={'[a-zA-Z0-9_]+'} '\s*' raw_value_ranges={'[0-9-,\s]+;'}
* .id = number {return parseInt(raw_id,10);}
* .value_ranges = string[][] {return raw_value_ranges.replace(';','').replace(/\s/g,'').split(',').map((value)=>{return value.split('-');});}
* ValTable := 'VAL_TABLE_\s' name={'[a-zA-Z0-9_]+'} '\s' raw_table={'.*'}
* .enum = Map<number,string> {return table2Enum(raw_table.replace(';',''));}
* Val := 'VAL_\s' raw_id={'[0-9]+'} '\s' name={'[a-zA-Z0-9_]+'} '\s' raw_table={'.*'}
* .id = number {return parseInt(raw_id,10);}
* .enum = Map<number,string> {return table2Enum(raw_table.replace(';',''));}
* EnvironmentVal := 'VAL_\s' !'0-9' name={'[a-zA-Z0-9_]+'} '\s' raw_table={'.*'}
* .enum = Map<number,string> {return table2Enum(raw_table.replace(';',''));}
* Comment := 'CM_\s' !'[SG_|BO_|BU_|EV_]' raw_comment={'.*'}
* .comment = string {return cleanComment(raw_comment);}
* SignalComment := 'CM_ SG_\s' raw_id={'[0-9]+'} '\s' name={'[a-zA-Z0-9_]+'} '\s' raw_comment={'.*'}
* .comment = string {return cleanComment(raw_comment);}
* .id = number {return parseInt(raw_id,10);}
* MessageComment := 'CM_ BO_\s' raw_id={'[0-9]+'} '\s' raw_comment={'.*'}
* .comment = string {return cleanComment(raw_comment);}
* .id = number {return parseInt(raw_id,10);}
* NodeComment := 'CM_ BU_\s' name={'[a-zA-Z0-9_]+'} '\s' raw_comment={'.*'}
* .comment = string {return cleanComment(raw_comment);}
* GlobalAttribute := 'BA_DEF_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' type={'[A-Z]+'} '\s' raw_value={'.*'}
* .min = number {return extractMinVal(type, raw_value);}
* .max = number {return extractMaxVal(type, raw_value);}
* .enum = string[] {return extractOptions(type, raw_value);}
* MessageAttribute := 'BA_DEF_ BO_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' type={'[A-Z]+'} '\s'? raw_value={'.*'}
* .min = number {return extractMinVal(type, raw_value);}
* .max = number {return extractMaxVal(type, raw_value);}
* .enum = string[] {return extractOptions(type, raw_value);}
* EnvironmentAttribute := 'BA_DEF_ EV_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' type={'[A-Z]+'} '\s'? raw_value={'.*'}
* .min = number {return extractMinVal(type, raw_value);}
* .max = number {return extractMaxVal(type, raw_value);}
* .enum = string[] {return extractOptions(type, raw_value);}
* NodeAttribute := 'BA_DEF_ BU_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' type={'[A-Z]+'} '\s'? raw_value={'.*'}
* .min = number {return extractMinVal(type, raw_value);}
* .max = number {return extractMaxVal(type, raw_value);}
* .enum = string[] {return extractOptions(type, raw_value);}
* SignalAttribute := 'BA_DEF_ SG_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' type={'[A-Z]+'} '\s'? raw_value={'.*'}
* .min = number {return extractMinVal(type, raw_value);}
* .max = number {return extractMaxVal(type, raw_value);}
* .enum = string[] {return extractOptions(type, raw_value);}
* AttributeDefault := 'BA_DEF_DEF_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' raw_value={'.*'}
* .value = string {return cleanComment(raw_value);}
* AttributeValue := 'BA_\s+' '"'name={'[a-zA-Z0-9_]+'}'"' '\s' raw={'.*'}
* .type = string {return extractAttrType(raw);}
* .node = string {return extractAttrNode(this.type,raw);}
* .id = number {return parseInt(extractAttrId(this.type,raw),10);}
* .signal = string {return extractAttrSignalName(this.type,raw);}
* .value = string {return extractAttrVal(this.type,raw);}
* SigValType := 'SIG_VALTYPE_\s+' raw_id={'[0-9]+'} '\s+' name={'[a-zA-Z0-9_]+'} '\s*:\s*' raw_type={'1|2'}
* .id = number {return parseInt(raw_id,10);}
* .type = number {return parseInt(raw_type,10);}
*/
var ASTKinds;
(function (ASTKinds) {
ASTKinds["Choice_1"] = "Choice_1";
ASTKinds["Choice_2"] = "Choice_2";
ASTKinds["Choice_3"] = "Choice_3";
ASTKinds["Choice_4"] = "Choice_4";
ASTKinds["Choice_5"] = "Choice_5";
ASTKinds["Choice_6"] = "Choice_6";
ASTKinds["Choice_7"] = "Choice_7";
ASTKinds["Choice_8"] = "Choice_8";
ASTKinds["Choice_9"] = "Choice_9";
ASTKinds["Choice_10"] = "Choice_10";
ASTKinds["Choice_11"] = "Choice_11";
ASTKinds["Choice_12"] = "Choice_12";
ASTKinds["Choice_13"] = "Choice_13";
ASTKinds["Choice_14"] = "Choice_14";
ASTKinds["Choice_15"] = "Choice_15";
ASTKinds["Choice_16"] = "Choice_16";
ASTKinds["Choice_17"] = "Choice_17";
ASTKinds["Choice_18"] = "Choice_18";
ASTKinds["Choice_19"] = "Choice_19";
ASTKinds["Choice_20"] = "Choice_20";
ASTKinds["Choice_21"] = "Choice_21";
ASTKinds["Choice_22"] = "Choice_22";
ASTKinds["Choice_23"] = "Choice_23";
ASTKinds["Choice_24"] = "Choice_24";
ASTKinds["Choice_25"] = "Choice_25";
ASTKinds["Choice_26"] = "Choice_26";
ASTKinds["Choice_27"] = "Choice_27";
ASTKinds["Choice_28"] = "Choice_28";
ASTKinds["Choice_29"] = "Choice_29";
ASTKinds["BlankLine"] = "BlankLine";
ASTKinds["CanSignalGroup"] = "CanSignalGroup";
ASTKinds["CanSignalGroup_$0"] = "CanSignalGroup_$0";
ASTKinds["CanSignalGroup_$1"] = "CanSignalGroup_$1";
ASTKinds["CanSignalGroup_$2"] = "CanSignalGroup_$2";
ASTKinds["CanSignalGroup_$3"] = "CanSignalGroup_$3";
ASTKinds["MessageTransmitter"] = "MessageTransmitter";
ASTKinds["MessageTransmitter_$0"] = "MessageTransmitter_$0";
ASTKinds["MessageTransmitter_$1"] = "MessageTransmitter_$1";
ASTKinds["CanEnvironmentVariable"] = "CanEnvironmentVariable";
ASTKinds["CanEnvironmentVariable_$0"] = "CanEnvironmentVariable_$0";
ASTKinds["CanEnvironmentVariable_$1"] = "CanEnvironmentVariable_$1";
ASTKinds["CanEnvironmentVariable_$2"] = "CanEnvironmentVariable_$2";
ASTKinds["CanEnvironmentVariable_$3"] = "CanEnvironmentVariable_$3";
ASTKinds["CanEnvironmentVariable_$4"] = "CanEnvironmentVariable_$4";
ASTKinds["CanEnvironmentVariable_$5"] = "CanEnvironmentVariable_$5";
ASTKinds["CanEnvironmentVariable_$6"] = "CanEnvironmentVariable_$6";
ASTKinds["CanEnvironmentVariable_$7"] = "CanEnvironmentVariable_$7";
ASTKinds["CanEnvironmentVariable_$8"] = "CanEnvironmentVariable_$8";
ASTKinds["EnvironmentVarData"] = "EnvironmentVarData";
ASTKinds["EnvironmentVarData_$0"] = "EnvironmentVarData_$0";
ASTKinds["EnvironmentVarData_$1"] = "EnvironmentVarData_$1";
ASTKinds["EnvironmentVariableComment"] = "EnvironmentVariableComment";
ASTKinds["EnvironmentVariableComment_$0"] = "EnvironmentVariableComment_$0";
ASTKinds["EnvironmentVariableComment_$1"] = "EnvironmentVariableComment_$1";
ASTKinds["Version"] = "Version";
ASTKinds["Version_$0"] = "Version_$0";
ASTKinds["NewSymbol"] = "NewSymbol";
ASTKinds["BusSpeed"] = "BusSpeed";
ASTKinds["NewSymbolValue"] = "NewSymbolValue";
ASTKinds["NewSymbolValue_$0"] = "NewSymbolValue_$0";
ASTKinds["CanNode"] = "CanNode";
ASTKinds["CanNode_$0"] = "CanNode_$0";
ASTKinds["CanMessage"] = "CanMessage";
ASTKinds["CanMessage_$0"] = "CanMessage_$0";
ASTKinds["CanMessage_$1"] = "CanMessage_$1";
ASTKinds["CanMessage_$2"] = "CanMessage_$2";
ASTKinds["CanMessage_$3"] = "CanMessage_$3";
ASTKinds["CanSignal"] = "CanSignal";
ASTKinds["CanSignal_$0"] = "CanSignal_$0";
ASTKinds["CanSignal_$1"] = "CanSignal_$1";
ASTKinds["CanSignal_$2"] = "CanSignal_$2";
ASTKinds["CanSignal_$3"] = "CanSignal_$3";
ASTKinds["CanSignal_$4"] = "CanSignal_$4";
ASTKinds["CanSignal_$5"] = "CanSignal_$5";
ASTKinds["CanSignal_$6"] = "CanSignal_$6";
ASTKinds["CanSignal_$7"] = "CanSignal_$7";
ASTKinds["CanSignal_$8"] = "CanSignal_$8";
ASTKinds["CanSignal_$9"] = "CanSignal_$9";
ASTKinds["CanSignal_$10"] = "CanSignal_$10";
ASTKinds["CanSignal_$11"] = "CanSignal_$11";
ASTKinds["SignalMultiplexVal"] = "SignalMultiplexVal";
ASTKinds["SignalMultiplexVal_$0"] = "SignalMultiplexVal_$0";
ASTKinds["SignalMultiplexVal_$1"] = "SignalMultiplexVal_$1";
ASTKinds["SignalMultiplexVal_$2"] = "SignalMultiplexVal_$2";
ASTKinds["SignalMultiplexVal_$3"] = "SignalMultiplexVal_$3";
ASTKinds["ValTable"] = "ValTable";
ASTKinds["ValTable_$0"] = "ValTable_$0";
ASTKinds["ValTable_$1"] = "ValTable_$1";
ASTKinds["Val"] = "Val";
ASTKinds["Val_$0"] = "Val_$0";
ASTKinds["Val_$1"] = "Val_$1";
ASTKinds["Val_$2"] = "Val_$2";
ASTKinds["EnvironmentVal"] = "EnvironmentVal";
ASTKinds["EnvironmentVal_$0"] = "EnvironmentVal_$0";
ASTKinds["EnvironmentVal_$1"] = "EnvironmentVal_$1";
ASTKinds["Comment"] = "Comment";
ASTKinds["Comment_$0"] = "Comment_$0";
ASTKinds["SignalComment"] = "SignalComment";
ASTKinds["SignalComment_$0"] = "SignalComment_$0";
ASTKinds["SignalComment_$1"] = "SignalComment_$1";
ASTKinds["SignalComment_$2"] = "SignalComment_$2";
ASTKinds["MessageComment"] = "MessageComment";
ASTKinds["MessageComment_$0"] = "MessageComment_$0";
ASTKinds["MessageComment_$1"] = "MessageComment_$1";
ASTKinds["NodeComment"] = "NodeComment";
ASTKinds["NodeComment_$0"] = "NodeComment_$0";
ASTKinds["NodeComment_$1"] = "NodeComment_$1";
ASTKinds["GlobalAttribute"] = "GlobalAttribute";
ASTKinds["GlobalAttribute_$0"] = "GlobalAttribute_$0";
ASTKinds["GlobalAttribute_$1"] = "GlobalAttribute_$1";
ASTKinds["GlobalAttribute_$2"] = "GlobalAttribute_$2";
ASTKinds["MessageAttribute"] = "MessageAttribute";
ASTKinds["MessageAttribute_$0"] = "MessageAttribute_$0";
ASTKinds["MessageAttribute_$1"] = "MessageAttribute_$1";
ASTKinds["MessageAttribute_$2"] = "MessageAttribute_$2";
ASTKinds["EnvironmentAttribute"] = "EnvironmentAttribute";
ASTKinds["EnvironmentAttribute_$0"] = "EnvironmentAttribute_$0";
ASTKinds["EnvironmentAttribute_$1"] = "EnvironmentAttribute_$1";
ASTKinds["EnvironmentAttribute_$2"] = "EnvironmentAttribute_$2";
ASTKinds["NodeAttribute"] = "NodeAttribute";
ASTKinds["NodeAttribute_$0"] = "NodeAttribute_$0";
ASTKinds["NodeAttribute_$1"] = "NodeAttribute_$1";
ASTKinds["NodeAttribute_$2"] = "NodeAttribute_$2";
ASTKinds["SignalAttribute"] = "SignalAttribute";
ASTKinds["SignalAttribute_$0"] = "SignalAttribute_$0";
ASTKinds["SignalAttribute_$1"] = "SignalAttribute_$1";
ASTKinds["SignalAttribute_$2"] = "SignalAttribute_$2";
ASTKinds["AttributeDefault"] = "AttributeDefault";
ASTKinds["AttributeDefault_$0"] = "AttributeDefault_$0";
ASTKinds["AttributeDefault_$1"] = "AttributeDefault_$1";
ASTKinds["AttributeValue"] = "AttributeValue";
ASTKinds["AttributeValue_$0"] = "AttributeValue_$0";
ASTKinds["AttributeValue_$1"] = "AttributeValue_$1";
ASTKinds["SigValType"] = "SigValType";
ASTKinds["SigValType_$0"] = "SigValType_$0";
ASTKinds["SigValType_$1"] = "SigValType_$1";
ASTKinds["SigValType_$2"] = "SigValType_$2";
ASTKinds["$EOF"] = "$EOF";
})(ASTKinds || (ASTKinds = {}));
class CanSignalGroup {
constructor(raw_id, name, raw_group_number, raw_signal_string) {
this.kind = ASTKinds.CanSignalGroup;
this.raw_id = raw_id;
this.name = name;
this.raw_group_number = raw_group_number;
this.raw_signal_string = raw_signal_string;
this.signals = (() => {
return raw_signal_string.replace(';', '').split(' ');
})();
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.group_number = (() => {
return parseInt(raw_group_number, 10);
})();
}
}
class MessageTransmitter {
constructor(raw_id, raw_nodes) {
this.kind = ASTKinds.MessageTransmitter;
this.raw_id = raw_id;
this.raw_nodes = raw_nodes;
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.nodes = (() => {
return raw_nodes.replace(';', '').split(',');
})();
}
}
class CanEnvironmentVariable {
constructor(name, type, raw_min, raw_max, raw_unit, raw_inital_value, raw_ev_id, access_type, node) {
this.kind = ASTKinds.CanEnvironmentVariable;
this.name = name;
this.type = type;
this.raw_min = raw_min;
this.raw_max = raw_max;
this.raw_unit = raw_unit;
this.raw_inital_value = raw_inital_value;
this.raw_ev_id = raw_ev_id;
this.access_type = access_type;
this.node = node;
this.min = (() => {
return parseFloat(raw_min);
})();
this.max = (() => {
return parseFloat(raw_max);
})();
this.unit = (() => {
return cleanComment(raw_unit);
})();
this.initial_value = (() => {
return parseFloat(raw_inital_value);
})();
this.ev_id = (() => {
return parseInt(raw_ev_id, 10);
})();
}
}
class EnvironmentVarData {
constructor(name, raw_value) {
this.kind = ASTKinds.EnvironmentVarData;
this.name = name;
this.raw_value = raw_value;
this.value = (() => {
return parseInt(raw_value);
})();
}
}
class EnvironmentVariableComment {
constructor(name, raw_comment) {
this.kind = ASTKinds.EnvironmentVariableComment;
this.name = name;
this.raw_comment = raw_comment;
this.comment = (() => {
return cleanComment(raw_comment);
})();
}
}
class Version {
constructor(raw_version) {
this.kind = ASTKinds.Version;
this.raw_version = raw_version;
this.version = (() => {
return cleanComment(raw_version);
})();
}
}
class CanNode {
constructor(raw_node_string) {
this.kind = ASTKinds.CanNode;
this.raw_node_string = raw_node_string;
this.node_names = (() => {
return raw_node_string.split(' ');
})();
}
}
class CanMessage {
constructor(raw_id, name, raw_dlc, node) {
this.kind = ASTKinds.CanMessage;
this.raw_id = raw_id;
this.name = name;
this.raw_dlc = raw_dlc;
this.node = node;
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.dlc = (() => {
return parseInt(raw_dlc, 10);
})();
}
}
class CanSignal {
constructor(name, multiplex, raw_start_bit, raw_length, raw_endian, raw_signed, raw_factor, raw_offset, raw_min, raw_max, raw_unit, raw_node_str) {
this.kind = ASTKinds.CanSignal;
this.name = name;
this.multiplex = multiplex;
this.raw_start_bit = raw_start_bit;
this.raw_length = raw_length;
this.raw_endian = raw_endian;
this.raw_signed = raw_signed;
this.raw_factor = raw_factor;
this.raw_offset = raw_offset;
this.raw_min = raw_min;
this.raw_max = raw_max;
this.raw_unit = raw_unit;
this.raw_node_str = raw_node_str;
this.multiplexer = (() => {
return multiplex.includes('M');
})();
this.unit = (() => {
return cleanComment(raw_unit);
})();
this.nodes = (() => {
return raw_node_str.trim().split(',');
})();
this.start_bit = (() => {
return parseInt(raw_start_bit, 10);
})();
this.length = (() => {
return parseInt(raw_length, 10);
})();
this.endian = (() => {
return raw_endian === '1' ? 'Intel' : 'Motorola';
})();
this.signed = (() => {
return raw_signed === '-' ? true : false;
})();
this.factor = (() => {
return parseFloat(raw_factor);
})();
this.offset = (() => {
return parseFloat(raw_offset);
})();
this.min = (() => {
return parseFloat(raw_min);
})();
this.max = (() => {
return parseFloat(raw_max);
})();
}
}
class SignalMultiplexVal {
constructor(raw_id, name, switch_name, raw_value_ranges) {
this.kind = ASTKinds.SignalMultiplexVal;
this.raw_id = raw_id;
this.name = name;
this.switch_name = switch_name;
this.raw_value_ranges = raw_value_ranges;
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.value_ranges = (() => {
return raw_value_ranges.replace(';', '').replace(/\s/g, '').split(',').map((value) => { return value.split('-'); });
})();
}
}
class ValTable {
constructor(name, raw_table) {
this.kind = ASTKinds.ValTable;
this.name = name;
this.raw_table = raw_table;
this.enum = (() => {
return table2Enum(raw_table.replace(';', ''));
})();
}
}
class Val {
constructor(raw_id, name, raw_table) {
this.kind = ASTKinds.Val;
this.raw_id = raw_id;
this.name = name;
this.raw_table = raw_table;
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.enum = (() => {
return table2Enum(raw_table.replace(';', ''));
})();
}
}
class EnvironmentVal {
constructor(name, raw_table) {
this.kind = ASTKinds.EnvironmentVal;
this.name = name;
this.raw_table = raw_table;
this.enum = (() => {
return table2Enum(raw_table.replace(';', ''));
})();
}
}
class Comment {
constructor(raw_comment) {
this.kind = ASTKinds.Comment;
this.raw_comment = raw_comment;
this.comment = (() => {
return cleanComment(raw_comment);
})();
}
}
class SignalComment {
constructor(raw_id, name, raw_comment) {
this.kind = ASTKinds.SignalComment;
this.raw_id = raw_id;
this.name = name;
this.raw_comment = raw_comment;
this.comment = (() => {
return cleanComment(raw_comment);
})();
this.id = (() => {
return parseInt(raw_id, 10);
})();
}
}
class MessageComment {
constructor(raw_id, raw_comment) {
this.kind = ASTKinds.MessageComment;
this.raw_id = raw_id;
this.raw_comment = raw_comment;
this.comment = (() => {
return cleanComment(raw_comment);
})();
this.id = (() => {
return parseInt(raw_id, 10);
})();
}
}
class NodeComment {
constructor(name, raw_comment) {
this.kind = ASTKinds.NodeComment;
this.name = name;
this.raw_comment = raw_comment;
this.comment = (() => {
return cleanComment(raw_comment);
})();
}
}
class GlobalAttribute {
constructor(name, type, raw_value) {
this.kind = ASTKinds.GlobalAttribute;
this.name = name;
this.type = type;
this.raw_value = raw_value;
this.min = (() => {
return extractMinVal(type, raw_value);
})();
this.max = (() => {
return extractMaxVal(type, raw_value);
})();
this.enum = (() => {
return extractOptions(type, raw_value);
})();
}
}
class MessageAttribute {
constructor(name, type, raw_value) {
this.kind = ASTKinds.MessageAttribute;
this.name = name;
this.type = type;
this.raw_value = raw_value;
this.min = (() => {
return extractMinVal(type, raw_value);
})();
this.max = (() => {
return extractMaxVal(type, raw_value);
})();
this.enum = (() => {
return extractOptions(type, raw_value);
})();
}
}
class EnvironmentAttribute {
constructor(name, type, raw_value) {
this.kind = ASTKinds.EnvironmentAttribute;
this.name = name;
this.type = type;
this.raw_value = raw_value;
this.min = (() => {
return extractMinVal(type, raw_value);
})();
this.max = (() => {
return extractMaxVal(type, raw_value);
})();
this.enum = (() => {
return extractOptions(type, raw_value);
})();
}
}
class NodeAttribute {
constructor(name, type, raw_value) {
this.kind = ASTKinds.NodeAttribute;
this.name = name;
this.type = type;
this.raw_value = raw_value;
this.min = (() => {
return extractMinVal(type, raw_value);
})();
this.max = (() => {
return extractMaxVal(type, raw_value);
})();
this.enum = (() => {
return extractOptions(type, raw_value);
})();
}
}
class SignalAttribute {
constructor(name, type, raw_value) {
this.kind = ASTKinds.SignalAttribute;
this.name = name;
this.type = type;
this.raw_value = raw_value;
this.min = (() => {
return extractMinVal(type, raw_value);
})();
this.max = (() => {
return extractMaxVal(type, raw_value);
})();
this.enum = (() => {
return extractOptions(type, raw_value);
})();
}
}
class AttributeDefault {
constructor(name, raw_value) {
this.kind = ASTKinds.AttributeDefault;
this.name = name;
this.raw_value = raw_value;
this.value = (() => {
return cleanComment(raw_value);
})();
}
}
class AttributeValue {
constructor(name, raw) {
this.kind = ASTKinds.AttributeValue;
this.name = name;
this.raw = raw;
this.type = (() => {
return extractAttrType(raw);
})();
this.node = (() => {
return extractAttrNode(this.type, raw);
})();
this.id = (() => {
return parseInt(extractAttrId(this.type, raw), 10);
})();
this.signal = (() => {
return extractAttrSignalName(this.type, raw);
})();
this.value = (() => {
return extractAttrVal(this.type, raw);
})();
}
}
class SigValType {
constructor(raw_id, name, raw_type) {
this.kind = ASTKinds.SigValType;
this.raw_id = raw_id;
this.name = name;
this.raw_type = raw_type;
this.id = (() => {
return parseInt(raw_id, 10);
})();
this.type = (() => {
return parseInt(raw_type, 10);
})();
}
}
class Parser {
constructor(input) {
this.negating = false;
this.memoSafe = true;
this.pos = { overallPos: 0, line: 1, offset: 0 };
this.input = input;
}
reset(pos) {
this.pos = pos;
}
finished() {
return this.pos.overallPos === this.input.length;
}
clearMemos() {
}
matchChoice($$dpth, $$cr) {
return this.choice([
() => this.matchChoice_1($$dpth + 1, $$cr),
() => this.matchChoice_2($$dpth + 1, $$cr),
() => this.matchChoice_3($$dpth + 1, $$cr),
() => this.matchChoice_4($$dpth + 1, $$cr),
() => this.matchChoice_5($$dpth + 1, $$cr),
() => this.matchChoice_6($$dpth + 1, $$cr),
() => this.matchChoice_7($$dpth + 1, $$cr),
() => this.matchChoice_8($$dpth + 1, $$cr),
() => this.matchChoice_9($$dpth + 1, $$cr),
() => this.matchChoice_10($$dpth + 1, $$cr),
() => this.matchChoice_11($$dpth + 1, $$cr),
() => this.matchChoice_12($$dpth + 1, $$cr),
() => this.matchChoice_13($$dpth + 1, $$cr),
() => this.matchChoice_14($$dpth + 1, $$cr),
() => this.matchChoice_15($$dpth + 1, $$cr),
() => this.matchChoice_16($$dpth + 1, $$cr),
() => this.matchChoice_17($$dpth + 1, $$cr),
() => this.matchChoice_18($$dpth + 1, $$cr),
() => this.matchChoice_19($$dpth + 1, $$cr),
() => this.matchChoice_20($$dpth + 1, $$cr),
() => this.matchChoice_21($$dpth + 1, $$cr),
() => this.matchChoice_22($$dpth + 1, $$cr),
() => this.matchChoice_23($$dpth + 1, $$cr),
() => this.matchChoice_24($$dpth + 1, $$cr),
() => this.matchChoice_25($$dpth + 1, $$cr),
() => this.matchChoice_26($$dpth + 1, $$cr),
() => this.matchChoice_27($$dpth + 1, $$cr),
() => this.matchChoice_28($$dpth + 1, $$cr),
() => this.matchChoice_29($$dpth + 1, $$cr),
]);
}
matchChoice_1($$dpth, $$cr) {
return this.matchCanNode($$dpth + 1, $$cr);
}
matchChoice_2($$dpth, $$cr) {
return this.matchCanMessage($$dpth + 1, $$cr);
}
matchChoice_3($$dpth, $$cr) {
return this.matchSignalMultiplexVal($$dpth + 1, $$cr);
}
matchChoice_4($$dpth, $$cr) {
return this.matchCanSignal($$dpth + 1, $$cr);
}
matchChoice_5($$dpth, $$cr) {
return this.matchValTable($$dpth + 1, $$cr);
}
matchChoice_6($$dpth, $$cr) {
return this.matchVal($$dpth + 1, $$cr);
}
matchChoice_7($$dpth, $$cr) {
return this.matchSignalComment($$dpth + 1, $$cr);
}
matchChoice_8($$dpth, $$cr) {
return this.matchMessageComment($$dpth + 1, $$cr);
}
matchChoice_9($$dpth, $$cr) {
return this.matchNodeComment($$dpth + 1, $$cr);
}
matchChoice_10($$dpth, $$cr) {
return this.matchGlobalAttribute($$dpth + 1, $$cr);
}
matchChoice_11($$dpth, $$cr) {
return this.matchMessageAttribute($$dpth + 1, $$cr);
}
matchChoice_12($$dpth, $$cr) {
return this.matchSignalAttribute($$dpth + 1, $$cr);
}
matchChoice_13($$dpth, $$cr) {
return this.matchNodeAttribute($$dpth + 1, $$cr);
}
matchChoice_14($$dpth, $$cr) {
return this.matchAttributeDefault($$dpth + 1, $$cr);
}
matchChoice_15($$dpth, $$cr) {
return this.matchAttributeValue($$dpth + 1, $$cr);
}
matchChoice_16($$dpth, $$cr) {
return this.matchVersion($$dpth + 1, $$cr);
}
matchChoice_17($$dpth, $$cr) {
return this.matchNewSymbolValue($$dpth + 1, $$cr);
}
matchChoice_18($$dpth, $$cr) {
return this.matchBlankLine($$dpth + 1, $$cr);
}
matchChoice_19($$dpth, $$cr) {
return this.matchNewSymbol($$dpth + 1, $$cr);
}
matchChoice_20($$dpth, $$cr) {
return this.matchBusSpeed($$dpth + 1, $$cr);
}
matchChoice_21($$dpth, $$cr) {
return this.matchComment($$dpth + 1, $$cr);
}
matchChoice_22($$dpth, $$cr) {
return this.matchCanEnvironmentVariable($$dpth + 1, $$cr);
}
matchChoice_23($$dpth, $$cr) {
return this.matchEnvironmentVarData($$dpth + 1, $$cr);
}
matchChoice_24($$dpth, $$cr) {
return this.matchEnvironmentVariableComment($$dpth + 1, $$cr);
}
matchChoice_25($$dpth, $$cr) {
return this.matchMessageTransmitter($$dpth + 1, $$cr);
}
matchChoice_26($$dpth, $$cr) {
return this.matchEnvironmentAttribute($$dpth + 1, $$cr);
}
matchChoice_27($$dpth, $$cr) {
return this.matchEnvironmentVal($$dpth + 1, $$cr);
}
matchChoice_28($$dpth, $$cr) {
return this.matchCanSignalGroup($$dpth + 1, $$cr);
}
matchChoice_29($$dpth, $$cr) {
return this.matchSigValType($$dpth + 1, $$cr);
}
matchBlankLine($$dpth, $$cr) {
return this.run($$dpth, () => {
let $$res = null;
if (this.regexAccept(String.raw `(?:)`, "", $$dpth + 1, $$cr) !== null
&& this.match$EOF($$cr) !== null) {
$$res = { kind: ASTKinds.BlankLine, };
}
return $$res;
});
}
matchCanSignalGroup($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$raw_id;
let $scope$name;
let $scope$raw_group_number;
let $scope$raw_signal_string;
let $$res = null;
if (this.regexAccept(String.raw `(?:SIG_GROUP_\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_id = this.matchCanSignalGroup_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$name = this.matchCanSignalGroup_$1($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_group_number = this.matchCanSignalGroup_$2($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_signal_string = this.matchCanSignalGroup_$3($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s*)`, "", $$dpth + 1, $$cr) !== null) {
$$res = new CanSignalGroup($scope$raw_id, $scope$name, $scope$raw_group_number, $scope$raw_signal_string);
}
return $$res;
});
}
matchCanSignalGroup_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[0-9]+)`, "", $$dpth + 1, $$cr);
}
matchCanSignalGroup_$1($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchCanSignalGroup_$2($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[0-9]+)`, "", $$dpth + 1, $$cr);
}
matchCanSignalGroup_$3($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_\s]*)`, "", $$dpth + 1, $$cr);
}
matchMessageTransmitter($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$raw_id;
let $scope$raw_nodes;
let $$res = null;
if (this.regexAccept(String.raw `(?:BO_TX_BU_\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_id = this.matchMessageTransmitter_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s*:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_nodes = this.matchMessageTransmitter_$1($$dpth + 1, $$cr)) !== null) {
$$res = new MessageTransmitter($scope$raw_id, $scope$raw_nodes);
}
return $$res;
});
}
matchMessageTransmitter_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[0-9]+)`, "", $$dpth + 1, $$cr);
}
matchMessageTransmitter_$1($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:.*)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$name;
let $scope$type;
let $scope$raw_min;
let $scope$raw_max;
let $scope$raw_unit;
let $scope$raw_inital_value;
let $scope$raw_ev_id;
let $scope$access_type;
let $scope$node;
let $$res = null;
if (this.regexAccept(String.raw `(?:EV_\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$name = this.matchCanEnvironmentVariable_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s*:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$type = this.matchCanEnvironmentVariable_$1($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+\[)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_min = this.matchCanEnvironmentVariable_$2($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\|)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_max = this.matchCanEnvironmentVariable_$3($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\]\s)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_unit = this.matchCanEnvironmentVariable_$4($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_inital_value = this.matchCanEnvironmentVariable_$5($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_ev_id = this.matchCanEnvironmentVariable_$6($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$access_type = this.matchCanEnvironmentVariable_$7($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$node = this.matchCanEnvironmentVariable_$8($$dpth + 1, $$cr)) !== null) {
$$res = new CanEnvironmentVariable($scope$name, $scope$type, $scope$raw_min, $scope$raw_max, $scope$raw_unit, $scope$raw_inital_value, $scope$raw_ev_id, $scope$access_type, $scope$node);
}
return $$res;
});
}
matchCanEnvironmentVariable_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$1($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:0|1|2)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$2($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[\-0-9.]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$3($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[\-0-9.]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$4($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:".*")`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$5($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[\-0-9.]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$6($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[0-9]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$7($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchCanEnvironmentVariable_$8($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchEnvironmentVarData($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$name;
let $scope$raw_value;
let $$res = null;
if (this.regexAccept(String.raw `(?:ENVVAR_DATA_\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$name = this.matchEnvironmentVarData_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s*:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_value = this.matchEnvironmentVarData_$1($$dpth + 1, $$cr)) !== null) {
$$res = new EnvironmentVarData($scope$name, $scope$raw_value);
}
return $$res;
});
}
matchEnvironmentVarData_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchEnvironmentVarData_$1($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[0-9]+)`, "", $$dpth + 1, $$cr);
}
matchEnvironmentVariableComment($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$name;
let $scope$raw_comment;
let $$res = null;
if (this.regexAccept(String.raw `(?:CM_ EV_\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$name = this.matchEnvironmentVariableComment_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_comment = this.matchEnvironmentVariableComment_$1($$dpth + 1, $$cr)) !== null) {
$$res = new EnvironmentVariableComment($scope$name, $scope$raw_comment);
}
return $$res;
});
}
matchEnvironmentVariableComment_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z0-9_]+)`, "", $$dpth + 1, $$cr);
}
matchEnvironmentVariableComment_$1($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:.*)`, "", $$dpth + 1, $$cr);
}
matchVersion($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$raw_version;
let $$res = null;
if (this.regexAccept(String.raw `(?:VERSION)`, "", $$dpth + 1, $$cr) !== null
&& this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_version = this.matchVersion_$0($$dpth + 1, $$cr)) !== null) {
$$res = new Version($scope$raw_version);
}
return $$res;
});
}
matchVersion_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:.*)`, "", $$dpth + 1, $$cr);
}
matchNewSymbol($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:NS_\s*:)`, "", $$dpth + 1, $$cr);
}
matchBusSpeed($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:BS_:)`, "", $$dpth + 1, $$cr);
}
matchNewSymbolValue($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$symbol;
let $$res = null;
if (this.regexAccept(String.raw `(?:\s+)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$symbol = this.matchNewSymbolValue_$0($$dpth + 1, $$cr)) !== null
&& ((this.regexAccept(String.raw `(?:$)`, "", $$dpth + 1, $$cr)) || true)) {
$$res = { kind: ASTKinds.NewSymbolValue, symbol: $scope$symbol };
}
return $$res;
});
}
matchNewSymbolValue_$0($$dpth, $$cr) {
return this.regexAccept(String.raw `(?:[a-zA-Z_]+_)`, "", $$dpth + 1, $$cr);
}
matchCanNode($$dpth, $$cr) {
return this.run($$dpth, () => {
let $scope$raw_node_string;
let $$res = null;
if (this.regexAccept(String.raw `(?:BU_:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ($scope$raw_node_string = this.matchCanNode_$0($$dpth + 1, $$cr)) !== null
&& this.regexAccept(String.raw `(?:\s*)`, "", $$dpth + 1, $$cr) !== null
&& ((this.regexAccept(String.raw `(?:;)`, "", $$dpth + 1, $$cr)) || true)) {
$$res = new CanNode($scope$raw_node_string);
}
return $$res;
});
}
matchCanNode_$0($$dpth, $$cr) {
return this.regexAccept(Str