Here comes the mercurial patch with both the _LOC_ in urweb.lex and the
"assert" function in top.ur
El 03/06/15 a les 14:43, Adam Chlipala ha escrit:
BTW, "let ... where ... end" is not documented in the reference manual.
No, it's there, on page 19 of the current version.
It is not in the "4.2 Core syntax" section, expression production,
I see that it is in the next "4.3 Shorthands" section that requires a
more attentive reading.
# HG changeset patch
# User Gabriel Riba Faura <[email protected]>
# Date 1433313263 -7200
# Node ID 763ccca119bc00e81a615d043429d83b7ef6118b
# Parent 854d7ba67a5929f53e2547311b5f506055f18222
location literal _LOC_
diff -r 854d7ba67a59 -r 763ccca119bc src/urweb.lex
--- a/src/urweb.lex Thu May 28 10:28:15 2015 -0400
+++ b/src/urweb.lex Wed Jun 03 08:34:23 2015 +0200
@@ -537,6 +537,12 @@
<INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
+<INITIAL> "_LOC_" => (let val strLoc = ErrorMsg.spanToString (ErrorMsg.spanOf
+ (pos yypos, pos yypos + size yytext))
+ in
+ Tokens.STRING (strLoc, pos yypos, pos yypos + size yytext)
+ end);
+
<INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext));
<INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext));
# HG changeset patch
# User Gabriel Riba Faura <[email protected]>
# Date 1433336866 -7200
# Node ID 6e8326bc459a63fcac90189c3e662b2aa2dba1a3
# Parent 763ccca119bc00e81a615d043429d83b7ef6118b
assert function to use with location literal _LOC_
diff -r 763ccca119bc -r 6e8326bc459a lib/ur/top.ur
--- a/lib/ur/top.ur Wed Jun 03 08:34:23 2015 +0200
+++ b/lib/ur/top.ur Wed Jun 03 15:07:46 2015 +0200
@@ -410,3 +410,7 @@
if x > y then x else y
fun min [t] ( _ : ord t) (x : t) (y : t) : t =
if x < y then x else y
+
+fun assert [a] (cond: bool) (msg: string) (loc: string) (x:a): a =
+
+ if cond then x else error <xml>{[msg]} at {[loc]}</xml>
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur