//MatchRules will try to match the tokens passed with rules existing in the interpreter
//If no match is found, will return nil
MatchRules will try to match the tokens passed with rules existing in the interpreter
If no match is found, will return nil
// MatchRules will try to match the tokens passed with rules existing in the interpreter // If no match is found will return nil
func MatchRules(tokens []FastToken) []Rule {
	result := []Rule{}
	tokPattern := BuildPattern(tokens)
	for _, gr := range rules {
		for _, r := range gr.Rules {
			if r.Disabled {
				continue
			}
			pos := r.Pattern.Matches(tokPattern)
			if len(pos) > 0 {
				newRule := Rule{Name: r.Name, Matches: pos, Resolve: r.Resolve}
				copy(newRule.Template, r.Template)
				result = append(result, newRule)
			}
		}
	}
	return result
}
func MatchRules ( tokens [ ] FastToken ) [ ] Rule { result := [ ] Rule { } tokPattern := BuildPattern ( tokens ) for _ , gr := range rules { for _ , r := range gr . Rules { if r . Disabled { continue } pos := r . Pattern . Matches ( tokPattern ) if len ( pos ) > 0 { newRule := Rule { Name : r . Name , Matches : pos , Resolve : r . Resolve } copy ( newRule . Template , r . Template ) result = append ( result , newRule ) } } } return result }
MatchRules will try to match the tokens passed with rules existing in the interpreter
If no match is found, will return nil
MatchRules will try to match the tokens passed with rules existing in the interpreter If no match is found will return nil
/*
	 * We will first build a pattern for the given tokens
	 * Then will match with the existing rule patterns using kmp
	 */ //building the pattern //trying to find matches for the rules with the token pattern //if the disabled skip the rule