in wasm/wasm-sharding-js/sharding/strgen.js [141:229]
determineOperator(operator) { // if an operator was found in operatorComparison, find out what operator it is and respond
if (operator != "") {
this.createLogEntry("Operator", operator);
switch(operator) {
case "[":
this.getCharacterSet();
break;
case "]":
this.createLogEntry("End of range reached", this.generated_value_list.toString());
if (this.lookahead() != '{' && !this.symbol_quantifiers.includes(this.lookahead())){
this.buildGeneratedString(this.selectValueFromList(1, undefined, this.allow_duplicate_characters));
}
break;
case "{":
this.quantifier_value = this.getQuantifier();
break;
case "}":
if (this.quantifier_value == 0) {
this.createLogEntry("End of quantifier reached", "0");
this.createLogEntry("No generation as quantifier is 0");
this.createLogEntry("Clearing values list...");
this.generated_value_list = [];
} else {
this.createLogEntry("End of quantifier reached", this.quantifier_value);
this.createLogEntry("Contents of value list", this.generated_value_list.toString());
this.buildGeneratedString(this.selectValueFromList(this.quantifier_value, undefined, this.allow_duplicate_characters));
}
this.quantifier_value = 1;
break;
case '(':
this.generateSequence();
break;
case ')':
this.createLogEntry("End of sequence reached");
if (this.temporary_value_list.length >= 1) {
this.generated_value_list = this.generated_value_list.concat(this.temporary_value_list);
this.temporary_value_list = [];
}
if (this.lookahead() != '{' && !this.symbol_quantifiers.includes(this.lookahead())){
this.createLogEntry("Contents of value list", this.generated_value_list.toString());
this.buildGeneratedString(this.selectValueFromList(1, undefined, false));
}
break;
case '/':
this.next();
this.getLiteral();
break;
case '+':
case '*':
case '?':
this.quantifier_value = this.getQuantifier();
if (this.quantifier_value == 0) {
this.createLogEntry("Symbol quantifier reached", "0");
this.createLogEntry("No generation as quantifier is 0");
this.createLogEntry("Clearing values list...");
this.generated_value_list = [];
} else {
this.createLogEntry("Symbol quantifier reached", this.quantifier_value);
this.createLogEntry("Final contents of value list", this.generated_value_list.toString());
this.buildGeneratedString(this.selectValueFromList(this.quantifier_value, undefined, this.allow_duplicate_characters));
}
this.quantifier_value = 1;
break;
default:
if (!this.symbol_quantifiers.includes(this.lookahead())) {
this.getLiteral();
} else {
this.addCharToList(this.current());
}
break;
}
this.operatorComparison();
} else {
if (this.reporting_type == 'full') { // report the full information at the end, if reporting is set to full
if (this.error_state) {
this.createLogEntry("End of pattern reached - string failed to generate due to error", undefined, true);
} else if (this.generated_output == "") {
this.createLogEntry("End of pattern reached - no string generated", undefined, true);
} else {
this.createLogEntry("End of pattern reached - final generated string", this.outputString(), true);
}
} else if (this.reporting_type == "less") { // report complete generation at the end, if reporting is set to less
this.createLogEntry("Strgen-JS - finish", undefined, true);
}
}
};