Using fslex I would like to return multiple tokens for one pattern but I don't see a way how to accomplish that. Even to use another rule function that returns multiple tokens would work for me.
I am trying to use something like this:
let identifier = [ 'a'-'z' 'A'-'Z' ]+
// ...
rule tokenize = parse
// ...
| '.' identifier '(' { let value = lexeme lexbuf
match operations.TryFind(value) with
// TODO: here is the problem:
// I would like to return like [DOT; op; LPAREN]
| Some op -> op
| None -> ID(value) }
| identifier { ID (lexeme lexbuf) }
// ...
The problem I am trying to solve here is to match for predefined tokens (see: operations
map) only if the identifier
is between .
and (
. Otherwise the match should be returned as an ID
.
I am fairly new to fslex so I am happy for any pointers in the right direction.