[Ur] Proposed location literals to track caller's location in error msgs.

Gabriel Riba gabriel at xarxaire.com
Tue May 26 09:41:38 EDT 2015


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)










-------------- next part --------------
A non-text attachment was scrubbed...
Name: urweb.grm.patch
Type: text/x-patch
Size: 1132 bytes
Desc: not available
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150526/7538ebf9/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urweb.lex.patch
Type: text/x-patch
Size: 526 bytes
Desc: not available
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150526/7538ebf9/attachment-0001.bin>


More information about the Ur mailing list