private IRule GetRegisterMap(IFluentParserConfigurator config) { var register = config.Rule(); register.IsMadeUp.By(constants).As("Name").WhenFound(f => this.valueMap[f.Name]).Or. By(registers).As("Name").WhenFound(f => this.valueMap[f.Name]).Or. By("[").Followed.By(registers).As("Name").Followed.By("]").WhenFound(f => (ushort) (this.valueMap[f.Name] + 0x8)).Or. By("[").Followed.By(hex).As("Hex").Followed.By("+").Followed.By(register).As("Reg").Followed.By("]").WhenFound(f => this.instructionResolver.ResolveRegisterPointer(f.Hex, f.Reg)).Or. By("[").Followed.By(hex).As("Hex").Followed.By("]").WhenFound(f => this.instructionResolver.ResolveNextWord(f.Hex)).Or. By(hex).As("Hex").WhenFound(f => this.instructionResolver.ResolveHex(f.Hex)).Or. By(digit).As("Digit").WhenFound(f => this.instructionResolver.ResolveLiteralValue(f.Digit)).Or. By("[").Followed.By(label).As("Label").Followed.By("+").Followed.By(registers).As("Reg").Followed.By("]").WhenFound(f => this.instructionResolver.ResolveLabelAndRegister(f.Label, f.Reg)).Or. By(label); return register; }
private void SetupExpressions(IFluentParserConfigurator config) { constants = config.Expression(); constants.ThatMatches("PC|SP|O|POP|PEEK|PUSH").AndReturns(f => f); registers = config.Expression(); registers.ThatMatches(@"[ABCXYZIJ]").AndReturns(f => f); digit = config.Expression(); digit.ThatMatches(@"\d|1\d|0\d").AndReturns(f =>f); hex = config.Expression(); hex.ThatMatches(@"0[xX][0-9a-fA-F]{1:4}").AndReturns(f => f); label = config.Expression(); label.ThatMatches(@"[a-zA-Z]\w+").AndReturns(f => f); }
private IRule DataParts(IFluentParserConfigurator config) { var datarules = config.Rule(); datarules.IsMadeUp.By(config.QuotedString).As("String").WhenFound(f => f).Or .By(hex).As("Binary").WhenFound(f => f).Or .By(digit).As("Digit").WhenFound(f => f); return datarules; }