public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Emit error for undefined operands
@ 2001-03-20 23:01 Ben Elliston
  2001-03-20 23:11 ` Ben Elliston
  2001-03-21  5:01 ` Frank Ch. Eigler
  0 siblings, 2 replies; 5+ messages in thread
From: Ben Elliston @ 2001-03-20 23:01 UTC (permalink / raw)
  To: cgen

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Patch] Emit error for undefined operands
  2001-03-20 23:01 [Patch] Emit error for undefined operands Ben Elliston
@ 2001-03-20 23:11 ` Ben Elliston
  2001-03-21  5:01 ` Frank Ch. Eigler
  1 sibling, 0 replies; 5+ messages in thread
From: Ben Elliston @ 2001-03-20 23:11 UTC (permalink / raw)
  To: cgen

>>>>> "Ben" == Ben Elliston <bje@redhat.com> writes:

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

Please disregard the last message on this subject.  Here's a much
cleaner version that utilises the function (current-op-lookup).  Okay?


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 -c -r1.21 opc-itab.scm
*** opc-itab.scm	2001/03/20 19:49:10	1.21
--- opc-itab.scm	2001/03/21 07:09:42
***************
*** 162,167 ****
--- 162,172 ----
  						  (substring syn 2 n)))
  						"), ")))))
  		 (let ((n (id-len (string-drop1 syn))))
 		   (if (= n 0)
 		       (parse-error context "empty or invalid operand name" syntax))
+ 		   (let ((operand (string->symbol (substring syn 1 (1+ n)))))
+ 		     (if (not (current-op-lookup operand))
+ 			 (parse-error context "undefined operand " operand syntax)))
  		   (loop (string-drop (1+ n) syn)
  			 (string-append result op-macro " ("
  					(string-upcase

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch] Emit error for undefined operands
  2001-03-20 23:01 [Patch] Emit error for undefined operands Ben Elliston
  2001-03-20 23:11 ` Ben Elliston
@ 2001-03-21  5:01 ` Frank Ch. Eigler
  2001-03-21 13:34   ` Ben Elliston
  1 sibling, 1 reply; 5+ messages in thread
From: Frank Ch. Eigler @ 2001-03-21  5:01 UTC (permalink / raw)
  To: Ben Elliston; +Cc: cgen

Hi -

bje's second patch is fine, except that:

:   (let ((operands (map (lambda (x) (obj:name x)) (current-op-list)))
should be
#   (let ((operands (map obj:name (current-op-list)))

(The identity lambda function doesn't contribute much.)

- FChE
-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6uKYqVZbdDOm/ZT0RAt7vAJ4j1d7LXCcHZxplDYacIj1fe2HuLACfd90m
G2mEUbJwmJr4uOWHWmaNqeY=
=TiYT
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch] Emit error for undefined operands
  2001-03-21  5:01 ` Frank Ch. Eigler
@ 2001-03-21 13:34   ` Ben Elliston
  2001-03-21 13:56     ` Ben Elliston
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2001-03-21 13:34 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: cgen

>>>>> "Frank" == Frank Ch Eigler <fche@redhat.com> writes:

  Frank> bje's second patch is fine, except that:

  Frank> :   (let ((operands (map (lambda (x) (obj:name x)) (current-op-list)))
  Frank> should be
  Frank> #   (let ((operands (map obj:name (current-op-list)))

  Frank> (The identity lambda function doesn't contribute much.)

You must still be looking at my first attempt.  The second patch no
longer uses a local `operands' symbol, as it employs the help of
(current-op-lookup) instead.

Ben

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch] Emit error for undefined operands
  2001-03-21 13:34   ` Ben Elliston
@ 2001-03-21 13:56     ` Ben Elliston
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Elliston @ 2001-03-21 13:56 UTC (permalink / raw)
  To: Frank Ch. Eigler, cgen

>>>>> "Ben" == Ben Elliston <bje@redhat.com> writes:

  Frank> (The identity lambda function doesn't contribute much.)

  Ben> You must still be looking at my first attempt.  The second patch no
  Ben> longer uses a local `operands' symbol, as it employs the help of
  Ben> (current-op-lookup) instead.

I assume this is the only criticism you had, so I've checked in the
second attempt.  Hopefully it well help catch simple mistakes in
future.

Ben

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-03-21 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-20 23:01 [Patch] Emit error for undefined operands Ben Elliston
2001-03-20 23:11 ` Ben Elliston
2001-03-21  5:01 ` Frank Ch. Eigler
2001-03-21 13:34   ` Ben Elliston
2001-03-21 13:56     ` Ben Elliston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).