comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: Ada type (yacc)YYSTYPE is ?
Date: 1999/01/18
Date: 1999-01-18T00:00:00+00:00	[thread overview]
Message-ID: <36a39cec.1456120@news.pacbell.net> (raw)
In-Reply-To: 77vmri$sc3$1@nnrp1.dejanews.com

>What I did for my token analysis packages is I created an abstract tagged
>"token" type. That way the tag acts as the variant, and you can put whatever
A BNF production like
  name : simple_name
might have an action like 
  {$$ := $1;}
which would translate into something like
  yyval := yy.value_stack(yy.tos);
where yyval is a YYStype and yy.value_stack is an array of YYStype.
Would you define
  type YYStype is Root_Token'Class;   ?
I don't quite understand just how you are using the tagged type.

   What I think I'd like is compile time, rather than execution time,
type checking.  Instead of a single YYStype I'd rather have different
ones for different tokens.  Thus for intance
  subtype name_YYSType is -- a bounded string
  subtype param_YYStype is -- some appropriate record structure
and
  name : simple_name
would do an assignment where the types are both name_YYStype while
  param : formal_name COLON type_name
would have code
  {$$ := make_param($1,$3);}
where
  function make_param(formal_name, type_name : name_YYStype) return
param_YYStype;
   name :  simple_name TIC attribute_name
might be coded simply as
  {$$ := $1 & "'" $ $3;}
since the type would be bounded string and "&" is available.
Has anyone done that?  Does it work in practice?
    




  reply	other threads:[~1999-01-18  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-16  0:00 Ada type (yacc)YYSTYPE is ? tmoran
1999-01-17  0:00 ` Steven Hovater
1999-01-18  0:00 ` dennison
1999-01-18  0:00   ` Tom Moran [this message]
1999-01-19  0:00     ` dennison
1999-01-18  0:00 ` Tucker Taft
1999-01-18  0:00   ` Tom Moran
1999-01-19  0:00     ` Andrew W. Reynolds
1999-01-19  0:00       ` Tom Moran
1999-01-19  0:00         ` rdt
1999-01-19  0:00           ` Martin C. Carlisle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox