I'm looking for a function that returns different integer values by matching an input string for different expressions.
Here is how it could be, but syntax:
package main
func MatchType(data []byte) int {
%% machine scanner;
%% write data;
cs, p, pe, eof := 0, 0, len(data), len(data)
_ = eof
%%{
main := ( 0..120 '-first-' ) @{ return 1 } ;
main := ( 0..120 '-second-' ) @{ return 2 } ;
write init;
write exec;
}%%
return -1
}
Can anybody please advise?