From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,59ea45c31346f2c4 X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: Re: Ada type (yacc)YYSTYPE is ? Date: 1999/01/18 Message-ID: <36a39cec.1456120@news.pacbell.net>#1/1 X-Deja-AN: 434136107 References: <77qu4d$jt8@lotho.delphi.com> <77vmri$sc3$1@nnrp1.dejanews.com> X-Complaints-To: abuse@pacbell.net X-Trace: typhoon-sf.pbi.net 916692397 206.170.2.90 (Mon, 18 Jan 1999 12:46:37 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Mon, 18 Jan 1999 12:46:37 PDT Newsgroups: comp.lang.ada Date: 1999-01-18T00:00:00+00:00 List-Id: >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?