This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Patch] Emit error for undefined operands


Here is another patch (precariously close to the last one!) which
emits a parse error for undefined operands which appear in the syntax
string.  Okay to commit?


2001-03-21  Ben Elliston  <bje@redhat.com>

	* opc-itab.scm (compute-syntax): Emit a parse error if an operand
	given in a syntax string is undefined.

Index: opc-itab.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/opc-itab.scm,v
retrieving revision 1.21
diff -u -r1.21 opc-itab.scm
--- opc-itab.scm	2001/03/20 19:49:10	1.21
+++ opc-itab.scm	2001/03/21 06:58:23
@@ -162,6 +162,12 @@
 						  (substring syn 2 n)))
 						"), ")))))
 		 (let ((n (id-len (string-drop1 syn))))
		   (if (= n 0)
		       (parse-error context "empty or invalid operand name" syntax))
+		   (let ((operands (map (lambda (x) (obj:name x)) (current-op-list)))
+			 (operand (string->symbol (substring syn 1 (1+ n)))))
+		     (if (not (member operand operands))
+			 (parse-error context (string-append "undefined operand " operand) syntax)))
 		   (loop (string-drop (1+ n) syn)
 			 (string-append result op-macro " ("
 					(string-upcase


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]