[m-dev.] for review: parse "term `Var` term"

Peter Ross petdr at cs.mu.OZ.AU
Fri Feb 11 18:06:22 AEDT 2000


Hi,

For Fergus to review.

I am assuming that this should be backported to the 0.9.x branch as
well.


===================================================================


Estimated hours taken: 2

library/parser.m:
    Accept the syntax "term `Var` term" when parsing.


Index: parser.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/parser.m,v
retrieving revision 1.33
diff -u -r1.33 parser.m
--- parser.m	1999/07/12 07:44:37	1.33
+++ parser.m	2000/02/11 06:45:20
@@ -369,7 +369,18 @@
 				% infix manner.
 			{ Op0 = "`" }
 		->
-			parser__get_token(name(Op), _),
+			parser__get_token(OpToken, _),
+			(
+				{ OpToken = name(NameOp) }
+			->
+				{ Op = NameOp },
+				{ VariableTerm = [] }
+			;
+				{ OpToken = variable(VariableOp) },
+				{ Op = "" },
+				parser__add_var(VariableOp, Var),
+				{ VariableTerm = [term__variable(Var)] }
+			),
 			parser__get_token(name("`"), _),
 
 			{ OpPriority = 100 },
@@ -377,6 +388,7 @@
 			{ RightAssoc = x }
 		;
 			{ Op = Op0 },
+			{ VariableTerm = [] },
 			parser__get_ops_table(OpTable),
 			{ ops__lookup_infix_op(OpTable, Op,
 					OpPriority, LeftAssoc, RightAssoc) }
@@ -390,7 +402,8 @@
 		( { RightTerm0 = ok(RightTerm) } ->
 			parser__get_term_context(Context, TermContext),
 			{ OpTerm = term__functor(term__atom(Op),
-				[LeftTerm, RightTerm], TermContext) },
+				append(VariableTerm, [LeftTerm, RightTerm]),
+				TermContext) },
 			parser__parse_rest(MaxPriority, IsArg, OpPriority,
 				OpTerm, Term)
 		;

----
Peter Ross
PhD Student University of Melbourne
http://www.cs.mu.oz.au/~petdr/
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list