import ParserDebug from "../ParserDebug"; export default class Breakpoint { descends:boolean = false; ruleName:string; elementName:string; tokenName:string; failOnly:boolean = false; successOrFail:boolean = false; lineIndexStr:string; lineOnly:boolean = false; skipOnly:boolean = false; isAll:boolean = false; filter():number { if (this.ruleName) { if (this.successOrFail) { return ParserDebug.RULE_MATCH | ParserDebug.LINE_RULE_FAIL | ParserDebug.RULE_FAIL | ParserDebug.LINE_RULE_SKIP } else if (this.failOnly) { return ParserDebug.RULE_FAIL | ParserDebug.LINE_RULE_FAIL; } else if (this.skipOnly) { return ParserDebug.LINE_ELEMENT_SKIP | ParserDebug.LINE_RULE_SKIP; } return ParserDebug.RULE_MATCH | ParserDebug.LINE_RULE_MATCH | ParserDebug.RULE_BEFORE } if (this.elementName || this.tokenName) { if (this.successOrFail) { return ParserDebug.ELEMENT_MATCH | ParserDebug.ELEMENT_FAIL | ParserDebug.ELEMENT_SKIP; } else if (this.failOnly) { return ParserDebug.ELEMENT_FAIL; } else if (this.skipOnly) { return ParserDebug.ELEMENT_SKIP } return ParserDebug.ELEMENT_MATCH; } if (this.lineOnly) { if (this.successOrFail) { return ParserDebug.LINE_RULE_MATCH | ParserDebug.LINE_RULE_FAIL | ParserDebug.LINE_ELEMENT_SKIP | ParserDebug.LINE_RULE_SKIP; } else if (this.failOnly) { return ParserDebug.LINE_RULE_FAIL; } else if (this.skipOnly) { return ParserDebug.LINE_ELEMENT_SKIP | ParserDebug.LINE_RULE_SKIP; } return ParserDebug.LINE_RULE_MATCH; } //Assert.fail(); return 0; } show():string { var out:string = ""; out += this.isAll ? "* isAll " : ""; out += this.ruleName ? ("rule :" + this.ruleName + " " ) : "" out += this.elementName ? ("element ( " + this.elementName + " ) ") : ""; out += this.tokenName ? ("TOKEN: " + this.tokenName + " ") : ""; out += this.lineIndexStr ? ("line #" + this.lineIndexStr) : ""; out += this.failOnly ? "! - fails " : ""; out += this.successOrFail ? "* - success or fail " : ""; out += this.lineOnly ? "--> - line only " : ""; out += this.skipOnly ? "? - skipped only " : ""; out += this.descends ? "> " : ""; return out; } } // class