Why not just implement this functionality purely in the lexer, lexing
the special marker as a string literal with the right contents? You can
call [ErrorMsg.spanOf] directly in the lexer, rather than via its alias
[s] in the parser.
(I'm agnostic on exactly which token gets this treatment.)
On 05/26/2015 09:41 AM, Gabriel Riba wrote:
The simplest way to add the caller's location is to have a location
literal, in the spirit of PHP's __LINE__, and pass it as a string
parameter.
I am going to use the mlyacc error span meccanism and name the literal
_LOC_ (LOC surrounded by a single underscore).
Addtion to "urweb.lex":
<INITIAL> "_LOC_" => (Tokens.LOCATION (pos yypos, pos yypos + size
yytext));
Addition to "urweb.grm":
* In the terminals %term clause add
| LOCATION
* In the "eterm" production clause add
| LOCATION (let
val strLoc = ErrorMsg.spanToString (s
(LOCATIONleft, LOCATIONright))
in
(EPrim (Prim.String (Prim.Normal, strLoc)), s
(LOCATIONleft, LOCATIONright))
end)
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur