I use ocamllex to write lexer for a scripting language, but I have to deal with a conflict with my comment rule.
I want my command arguments not to be sorted if they contain only alphanumeric characters and slashes "/". For instance:
echo "quoted argument !@ #%" /this/second/argument/is/unquoted
Also, one of my preliminary requests is C ++ style comments using "//"
//this is a comment echo hello world
The problem that arises is things like
echo foo//comment
I would like my lexer to create the "foo" token, as well as leaving the "//" untouched, which will be used the next time I ask lexer for the token. Is it possible? . The reason for this is that it is possible that the input buffer has not yet reached the end of the comment, and I would rather return the βfooβ token immediately than an unnecessary block, trying to willingly consume the comment.
source share