[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: treecc/tests output17.out,NONE,1.1 output17.
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: treecc/tests output17.out,NONE,1.1 output17.tst,NONE,1.1 output18.out,NONE,1.1 output18.tst,NONE,1.1 test_list,1.4,1.5 |
Date: |
Fri, 04 Jul 2003 00:53:51 -0400 |
Update of /cvsroot/dotgnu-pnet/treecc/tests
In directory subversions:/tmp/cvs-serv32530/tests
Modified Files:
test_list
Added Files:
output17.out output17.tst output18.out output18.tst
Log Message:
Add the "gc_allocator" option to treecc, to make the node allocator use libgc.
--- NEW FILE ---
line 3: %option gc_allocator
line 5: %node expression no_parent 6
line 7: %field type type_code no_value 1
line 10: %node binary expression 2
line 12: %field expr1 expression * no_value 0
line 13: %field expr2 expression * no_value 0
line 16: %node unary expression 2
line 19: %field expr expression * no_value 0
line 23: %node intnum expression 0
line 25: %field num int no_value 0
line 28: %node plus binary 0
line 29: %node minus binary 0
line 30: %node multiply binary 0
line 31: %node divide binary 0
line 32: %node negate unary 0
line 33: %node power binary 0
line 35: %operation void infer_type 2
line 35: %param expression * e 1
line 37: %case binary infer_type
line 57: %case unary infer_type
line 63: %case intnum infer_type
line 68: %case power infer_type
/* output.h. Generated automatically by treecc */
#ifndef __yy_output_h
#define __yy_output_h
#ifdef __cplusplus
extern "C" {
#endif
#define expression_kind 1
#define binary_kind 2
#define unary_kind 3
#define intnum_kind 4
#define plus_kind 5
#define minus_kind 6
#define multiply_kind 7
#define divide_kind 8
#define power_kind 10
#define negate_kind 9
typedef struct expression__ expression;
typedef struct binary__ binary;
typedef struct unary__ unary;
typedef struct intnum__ intnum;
typedef struct plus__ plus;
typedef struct minus__ minus;
typedef struct multiply__ multiply;
typedef struct divide__ divide;
typedef struct power__ power;
typedef struct negate__ negate;
#line 1 "c_gc_skel.h"
typedef struct
{
int dummy__;
} YYNODESTATE;
#line 38 "output.h"
struct expression__ {
const struct expression_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
};
struct expression_vtable__ {
const void *parent__;
int kind__;
const char *name__;
};
extern struct expression_vtable__ const expression_vt__;
struct binary__ {
const struct binary_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct binary_vtable__ {
const struct expression_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct binary_vtable__ const binary_vt__;
struct unary__ {
const struct unary_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr;
};
struct unary_vtable__ {
const struct expression_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct unary_vtable__ const unary_vt__;
struct intnum__ {
const struct intnum_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
int num;
};
struct intnum_vtable__ {
const struct expression_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct intnum_vtable__ const intnum_vt__;
struct plus__ {
const struct plus_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct plus_vtable__ {
const struct binary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct plus_vtable__ const plus_vt__;
struct minus__ {
const struct minus_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct minus_vtable__ {
const struct binary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct minus_vtable__ const minus_vt__;
struct multiply__ {
const struct multiply_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct multiply_vtable__ {
const struct binary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct multiply_vtable__ const multiply_vt__;
struct divide__ {
const struct divide_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct divide_vtable__ {
const struct binary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct divide_vtable__ const divide_vt__;
struct power__ {
const struct power_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr1;
expression * expr2;
};
struct power_vtable__ {
const struct binary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct power_vtable__ const power_vt__;
struct negate__ {
const struct negate_vtable__ *vtable__;
int kind__;
char *filename__;
long linenum__;
type_code type;
expression * expr;
};
struct negate_vtable__ {
const struct unary_vtable__ *parent__;
int kind__;
const char *name__;
};
extern struct negate_vtable__ const negate_vt__;
extern expression *intnum_create(int num);
extern expression *plus_create(expression * expr1, expression * expr2);
extern expression *minus_create(expression * expr1, expression * expr2);
extern expression *multiply_create(expression * expr1, expression * expr2);
extern expression *divide_create(expression * expr1, expression * expr2);
extern expression *power_create(expression * expr1, expression * expr2);
extern expression *negate_create(expression * expr);
extern void infer_type(expression * e);
#ifndef yykind
#define yykind(node__) ((node__)->kind__)
#endif
#ifndef yykindname
#define yykindname(node__) ((node__)->vtable__->name__)
#endif
#ifndef yykindof
#define yykindof(type__) (type__##_kind)
#endif
#ifndef yyisa
extern int yyisa__(const void *vtable__, int kind__);
#define yyisa(node__,type__) \
(yyisa__((node__)->vtable__, (type__##_kind)))
#endif
#ifndef yygetfilename
#define yygetfilename(node__) ((node__)->filename__)
#endif
#ifndef yygetlinenum
#define yygetlinenum(node__) ((node__)->linenum__)
#endif
#ifndef yysetfilename
#define yysetfilename(node__, value__) \
((node__)->filename__ = (value__))
#endif
#ifndef yysetlinenum
#define yysetlinenum(node__, value__) \
((node__)->linenum__ = (value__))
#endif
#ifndef yytracklines_declared
extern char *yycurrfilename(void);
extern long yycurrlinenum(void);
#define yytracklines_declared 1
#endif
#ifndef yynodeops_declared
extern void yynodeinit(void);
extern void *yynodealloc(unsigned int size__);
extern int yynodepush(void);
extern void yynodepop(void);
extern void yynodeclear(void);
extern void yynodefailed(void);
#define yynodeops_declared 1
#endif
#ifdef __cplusplus
};
#endif
#endif
/* output.c. Generated automatically by treecc */
#define YYNODESTATE_TRACK_LINES 1
#line 1 "c_gc_skel.c"
/*
* treecc node allocation routines for C.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* As a special exception, when this file is copied by treecc into
* a treecc output file, you may use that output file without restriction.
*/
#include <stdlib.h>
#include <gc.h>
/*
* Initialize the node allocation pool.
*/
#ifdef YYNODESTATE_REENTRANT
void yynodeinit(state__)
YYNODESTATE *state__;
{
#else
void yynodeinit()
{
#endif
GC_INIT();
GC_init();
}
/*
* Allocate a block of memory.
*/
#ifdef YYNODESTATE_REENTRANT
void *yynodealloc(state__, size__)
YYNODESTATE *state__;
unsigned int size__;
{
#else
void *yynodealloc(size__)
unsigned int size__;
{
#endif
return (void *)GC_MALLOC((size_t)size__);
}
/*
* Push the node allocation state. Not used in the GC version.
*/
#ifdef YYNODESTATE_REENTRANT
int yynodepush(state__)
YYNODESTATE *state__;
{
#else
int yynodepush()
{
#endif
return 1;
}
/*
* Pop the node allocation state. Not used in the GC version.
*/
#ifdef YYNODESTATE_REENTRANT
void yynodepop(state__)
YYNODESTATE *state__;
{
#else
void yynodepop()
{
#endif
}
/*
* Clear the node allocation pool completely. Not used in the GC version.
*/
#ifdef YYNODESTATE_REENTRANT
void yynodeclear(state__)
YYNODESTATE *state__;
{
#else
void yynodeclear()
{
#endif
}
#line 102 "output.c"
struct expression_vtable__ const expression_vt__ = {
0,
expression_kind,
"expression",
};
struct binary_vtable__ const binary_vt__ = {
&expression_vt__,
binary_kind,
"binary",
};
struct unary_vtable__ const unary_vt__ = {
&expression_vt__,
unary_kind,
"unary",
};
struct intnum_vtable__ const intnum_vt__ = {
&expression_vt__,
intnum_kind,
"intnum",
};
struct plus_vtable__ const plus_vt__ = {
&binary_vt__,
plus_kind,
"plus",
};
struct minus_vtable__ const minus_vt__ = {
&binary_vt__,
minus_kind,
"minus",
};
struct multiply_vtable__ const multiply_vt__ = {
&binary_vt__,
multiply_kind,
"multiply",
};
struct divide_vtable__ const divide_vt__ = {
&binary_vt__,
divide_kind,
"divide",
};
struct power_vtable__ const power_vt__ = {
&binary_vt__,
power_kind,
"power",
};
struct negate_vtable__ const negate_vt__ = {
&unary_vt__,
negate_kind,
"negate",
};
expression *intnum_create(int num)
{
intnum *node__ = (intnum *)yynodealloc(sizeof(struct intnum__));
if(node__ == 0) return 0;
node__->vtable__ = &intnum_vt__;
node__->kind__ = intnum_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->num = num;
return (expression *)node__;
}
expression *plus_create(expression * expr1, expression * expr2)
{
plus *node__ = (plus *)yynodealloc(sizeof(struct plus__));
if(node__ == 0) return 0;
node__->vtable__ = &plus_vt__;
node__->kind__ = plus_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr1 = expr1;
node__->expr2 = expr2;
return (expression *)node__;
}
expression *minus_create(expression * expr1, expression * expr2)
{
minus *node__ = (minus *)yynodealloc(sizeof(struct minus__));
if(node__ == 0) return 0;
node__->vtable__ = &minus_vt__;
node__->kind__ = minus_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr1 = expr1;
node__->expr2 = expr2;
return (expression *)node__;
}
expression *multiply_create(expression * expr1, expression * expr2)
{
multiply *node__ = (multiply *)yynodealloc(sizeof(struct multiply__));
if(node__ == 0) return 0;
node__->vtable__ = &multiply_vt__;
node__->kind__ = multiply_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr1 = expr1;
node__->expr2 = expr2;
return (expression *)node__;
}
expression *divide_create(expression * expr1, expression * expr2)
{
divide *node__ = (divide *)yynodealloc(sizeof(struct divide__));
if(node__ == 0) return 0;
node__->vtable__ = ÷_vt__;
node__->kind__ = divide_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr1 = expr1;
node__->expr2 = expr2;
return (expression *)node__;
}
expression *power_create(expression * expr1, expression * expr2)
{
power *node__ = (power *)yynodealloc(sizeof(struct power__));
if(node__ == 0) return 0;
node__->vtable__ = &power_vt__;
node__->kind__ = power_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr1 = expr1;
node__->expr2 = expr2;
return (expression *)node__;
}
expression *negate_create(expression * expr)
{
negate *node__ = (negate *)yynodealloc(sizeof(struct negate__));
if(node__ == 0) return 0;
node__->vtable__ = &negate_vt__;
node__->kind__ = negate_kind;
node__->filename__ = yycurrfilename();
node__->linenum__ = yycurrlinenum();
node__->expr = expr;
return (expression *)node__;
}
void infer_type(expression * e__)
{
switch(e__->kind__)
{
case power_kind:
{
power *e = (power *)e__;
#line 69 "output17.tst"
{
infer_type(e->expr1);
infer_type(e->expr2);
if(e->expr2->type != int_type)
{
error("second sub-expression to `^' is
not an integer");
}
e->type = e->expr1->type;
}
#line 271 "output.c"
}
break;
case binary_kind:
case plus_kind:
case minus_kind:
case multiply_kind:
case divide_kind:
{
binary *e = (binary *)e__;
#line 38 "output17.tst"
{
type_code type1, type2;
infer_type(e->expr1);
type1 = e->expr1->type;
infer_type(e->expr2);
type2 = e->expr2->type;
if(type1 == float_type || type2 == float_type)
{
e->type = float_type;
}
else
{
e->type = int_type;
}
}
#line 301 "output.c"
}
break;
case unary_kind:
case negate_kind:
{
unary *e = (unary *)e__;
#line 58 "output17.tst"
{
infer_type(e->expr);
e->type = e->expr->type;
}
#line 314 "output.c"
}
break;
case intnum_kind:
{
intnum *e = (intnum *)e__;
#line 64 "output17.tst"
{
e->type = int_type;
}
#line 325 "output.c"
}
break;
default: break;
}
}
struct yy_vtable__ {
const struct yy_vtable__ *parent__;
int kind__;
};
int yyisa__(const void *vtable__, int kind__)
{
const struct yy_vtable__ *vt;
vt = (const struct yy_vtable__ *)vtable__;
while(vt != 0) {
if(vt->kind__ == kind__)
return 1;
vt = vt->parent__;
}
return 0;
}
--- NEW FILE ---
// test output logic for libgc
%option gc_allocator
%node expression %abstract %typedef =
{
%nocreate type_code type;
}
%node binary expression %abstract =
{
expression *expr1;
expression *expr2;
}
%node unary expression %abstract =
{
;
expression *expr;
;
}
%node intnum expression =
{
int num;
}
%node plus binary
%node minus binary
%node multiply binary
%node divide binary
%node negate unary
%node power binary
%operation %inline void infer_type(expression *e)
infer_type(binary)
{
type_code type1, type2;
infer_type(e->expr1);
type1 = e->expr1->type;
infer_type(e->expr2);
type2 = e->expr2->type;
if(type1 == float_type || type2 == float_type)
{
e->type = float_type;
}
else
{
e->type = int_type;
}
}
infer_type(unary)
{
infer_type(e->expr);
e->type = e->expr->type;
}
infer_type(intnum)
{
e->type = int_type;
}
infer_type(power)
{
infer_type(e->expr1);
infer_type(e->expr2);
if(e->expr2->type != int_type)
{
error("second sub-expression to `^' is not an integer");
}
e->type = e->expr1->type;
}
--- NEW FILE ---
line 3: %option lang C++
line 4: %option reentrant
line 5: %option gc_allocator
line 7: %node expression no_parent 6
line 9: %field type type_code no_value 1
line 12: %node binary expression 2
line 14: %field expr1 expression * no_value 0
line 15: %field expr2 expression * no_value 0
line 18: %node unary expression 2
line 20: %field expr expression * no_value 0
line 23: %node intnum expression 0
line 25: %field num int no_value 0
line 28: %node plus binary 0
line 29: %node minus binary 0
line 30: %node multiply binary 0
line 31: %node divide binary 0
line 32: %node negate unary 0
line 33: %node power binary 0
line 35: %operation void infer_type 1
line 35: %param expression * this 1
line 35: %virtual expression infer_type
line 37: %case binary infer_type
line 57: %case unary infer_type
line 63: %case intnum infer_type
line 68: %case power infer_type
/* output.h. Generated automatically by treecc */
#ifndef __yy_output_h
#define __yy_output_h
#include <new>
const int expression_kind = 1;
const int binary_kind = 2;
const int unary_kind = 3;
const int intnum_kind = 4;
const int plus_kind = 5;
const int minus_kind = 6;
const int multiply_kind = 7;
const int divide_kind = 8;
const int power_kind = 10;
const int negate_kind = 9;
class expression;
class binary;
class unary;
class intnum;
class plus;
class minus;
class multiply;
class divide;
class power;
class negate;
class YYNODESTATE
{
public:
YYNODESTATE();
virtual ~YYNODESTATE();
#line 1 "cpp_gc_skel.h"
#line 39 "output.h"
public:
intnum *intnumCreate(int num);
plus *plusCreate(expression * expr1, expression * expr2);
minus *minusCreate(expression * expr1, expression * expr2);
multiply *multiplyCreate(expression * expr1, expression * expr2);
divide *divideCreate(expression * expr1, expression * expr2);
power *powerCreate(expression * expr1, expression * expr2);
negate *negateCreate(expression * expr);
public:
void *alloc(size_t);
void dealloc(void *, size_t);
int push();
void pop();
void clear();
virtual void failed();
virtual char *currFilename();
virtual long currLinenum();
};
class expression
{
protected:
int kind__;
char *filename__;
long linenum__;
public:
int getKind() const { return kind__; }
const char *getFilename() const { return filename__; }
long getLinenum() const { return linenum__; }
void setFilename(char *filename) { filename__ = filename; }
void setLinenum(long linenum) { linenum__ = linenum; }
protected:
friend class YYNODESTATE;
expression(YYNODESTATE *state__);
public:
type_code type;
virtual void infer_type() = 0;
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~expression();
};
class binary : public expression
{
protected:
friend class YYNODESTATE;
binary(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
expression * expr1;
expression * expr2;
virtual void infer_type();
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~binary();
};
class unary : public expression
{
protected:
friend class YYNODESTATE;
unary(YYNODESTATE *state__, expression * expr);
public:
expression * expr;
virtual void infer_type();
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~unary();
};
class intnum : public expression
{
protected:
friend class YYNODESTATE;
intnum(YYNODESTATE *state__, int num);
public:
int num;
virtual void infer_type();
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~intnum();
};
class plus : public binary
{
protected:
friend class YYNODESTATE;
plus(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~plus();
};
class minus : public binary
{
protected:
friend class YYNODESTATE;
minus(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~minus();
};
class multiply : public binary
{
protected:
friend class YYNODESTATE;
multiply(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~multiply();
};
class divide : public binary
{
protected:
friend class YYNODESTATE;
divide(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~divide();
};
class power : public binary
{
protected:
friend class YYNODESTATE;
power(YYNODESTATE *state__, expression * expr1, expression * expr2);
public:
virtual void infer_type();
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~power();
};
class negate : public unary
{
protected:
friend class YYNODESTATE;
negate(YYNODESTATE *state__, expression * expr);
public:
virtual int isA(int kind) const;
virtual const char *getKindName() const;
protected:
virtual ~negate();
};
#endif
/* output.c. Generated automatically by treecc */
#define YYNODESTATE_REENTRANT 1
#define YYNODESTATE_TRACK_LINES 1
#define YYNODESTATE_USE_ALLOCATOR 1
#line 1 "cpp_gc_skel.cc"
/*
* treecc node allocation routines for C++.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* As a special exception, when this file is copied by treecc into
* a treecc output file, you may use that output file without restriction.
*/
#include <gc.h>
/*
* Initialize the singleton instance.
*/
#ifndef YYNODESTATE_REENTRANT
YYNODESTATE *YYNODESTATE::state__ = 0;
#endif
/*
* Constructor for YYNODESTATE.
*/
YYNODESTATE::YYNODESTATE()
{
/* Initialize the garbage collector */
GC_INIT();
GC_init();
#ifndef YYNODESTATE_REENTRANT
/* Register this object as the singleton instance */
if(!state__)
{
state__ = this;
}
#endif
}
/*
* Destructor for YYNODESTATE.
*/
YYNODESTATE::~YYNODESTATE()
{
#ifndef YYNODESTATE_REENTRANT
/* We are no longer the singleton instance */
if(state__ == this)
{
state__ = 0;
}
#endif
}
#ifdef YYNODESTATE_USE_ALLOCATOR
/*
* Allocate a block of memory.
*/
void *YYNODESTATE::alloc(size_t size__)
{
return (void *)GC_MALLOC((size_t)size__);
}
/*
* Deallocate a block of memory.
*/
void YYNODESTATE::dealloc(void *ptr__, size_t size__)
{
/* Nothing to do for this type of node allocator */
}
/*
* Push the node allocation state.
*/
int YYNODESTATE::push()
{
/* Not used with the garbage collector */
return 1;
}
/*
* Pop the node allocation state.
*/
void YYNODESTATE::pop()
{
/* Not used with the garbage collector */
}
/*
* Clear the node allocation pool completely.
*/
void YYNODESTATE::clear()
{
/* Not used with the garbage collector */
}
#endif /* YYNODESTATE_USE_ALLOCATOR */
/*
* Default implementation of functions which may be overridden.
*/
void YYNODESTATE::failed()
{
}
#ifdef YYNODESTATE_TRACK_LINES
char *YYNODESTATE::currFilename()
{
return (char *)0;
}
long YYNODESTATE::currLinenum()
{
return 0;
}
#endif
#line 137 "output.c"
intnum *YYNODESTATE::intnumCreate(int num)
{
void *buf__ = this->alloc(sizeof(intnum));
if(buf__ == 0) return 0;
return new (buf__) intnum(this, num);
}
plus *YYNODESTATE::plusCreate(expression * expr1, expression * expr2)
{
void *buf__ = this->alloc(sizeof(plus));
if(buf__ == 0) return 0;
return new (buf__) plus(this, expr1, expr2);
}
minus *YYNODESTATE::minusCreate(expression * expr1, expression * expr2)
{
void *buf__ = this->alloc(sizeof(minus));
if(buf__ == 0) return 0;
return new (buf__) minus(this, expr1, expr2);
}
multiply *YYNODESTATE::multiplyCreate(expression * expr1, expression * expr2)
{
void *buf__ = this->alloc(sizeof(multiply));
if(buf__ == 0) return 0;
return new (buf__) multiply(this, expr1, expr2);
}
divide *YYNODESTATE::divideCreate(expression * expr1, expression * expr2)
{
void *buf__ = this->alloc(sizeof(divide));
if(buf__ == 0) return 0;
return new (buf__) divide(this, expr1, expr2);
}
power *YYNODESTATE::powerCreate(expression * expr1, expression * expr2)
{
void *buf__ = this->alloc(sizeof(power));
if(buf__ == 0) return 0;
return new (buf__) power(this, expr1, expr2);
}
negate *YYNODESTATE::negateCreate(expression * expr)
{
void *buf__ = this->alloc(sizeof(negate));
if(buf__ == 0) return 0;
return new (buf__) negate(this, expr);
}
expression::expression(YYNODESTATE *state__)
{
this->kind__ = expression_kind;
this->filename__ = state__->currFilename();
this->linenum__ = state__->currLinenum();
}
expression::~expression()
{
// not used
}
int expression::isA(int kind) const
{
if(kind == expression_kind)
return 1;
else
return 0;
}
const char *expression::getKindName() const
{
return "expression";
}
binary::binary(YYNODESTATE *state__, expression * expr1, expression * expr2)
: expression(state__)
{
this->kind__ = binary_kind;
this->expr1 = expr1;
this->expr2 = expr2;
}
binary::~binary()
{
// not used
}
void binary::infer_type()
#line 38 "output18.tst"
{
type_code type1, type2;
expr1->infer_type();
type1 = expr1->type;
expr2->infer_type();
type2 = expr2->type;
if(type1 == float_type || type2 == float_type)
{
type = float_type;
}
else
{
type = int_type;
}
}
#line 245 "output.c"
int binary::isA(int kind) const
{
if(kind == binary_kind)
return 1;
else
return expression::isA(kind);
}
const char *binary::getKindName() const
{
return "binary";
}
unary::unary(YYNODESTATE *state__, expression * expr)
: expression(state__)
{
this->kind__ = unary_kind;
this->expr = expr;
}
unary::~unary()
{
// not used
}
void unary::infer_type()
#line 58 "output18.tst"
{
expr->infer_type();
type = expr->type;
}
#line 278 "output.c"
int unary::isA(int kind) const
{
if(kind == unary_kind)
return 1;
else
return expression::isA(kind);
}
const char *unary::getKindName() const
{
return "unary";
}
intnum::intnum(YYNODESTATE *state__, int num)
: expression(state__)
{
this->kind__ = intnum_kind;
this->num = num;
}
intnum::~intnum()
{
// not used
}
void intnum::infer_type()
#line 64 "output18.tst"
{
type = int_type;
}
#line 310 "output.c"
int intnum::isA(int kind) const
{
if(kind == intnum_kind)
return 1;
else
return expression::isA(kind);
}
const char *intnum::getKindName() const
{
return "intnum";
}
plus::plus(YYNODESTATE *state__, expression * expr1, expression * expr2)
: binary(state__, expr1, expr2)
{
this->kind__ = plus_kind;
}
plus::~plus()
{
// not used
}
int plus::isA(int kind) const
{
if(kind == plus_kind)
return 1;
else
return binary::isA(kind);
}
const char *plus::getKindName() const
{
return "plus";
}
minus::minus(YYNODESTATE *state__, expression * expr1, expression * expr2)
: binary(state__, expr1, expr2)
{
this->kind__ = minus_kind;
}
minus::~minus()
{
// not used
}
int minus::isA(int kind) const
{
if(kind == minus_kind)
return 1;
else
return binary::isA(kind);
}
const char *minus::getKindName() const
{
return "minus";
}
multiply::multiply(YYNODESTATE *state__, expression * expr1, expression * expr2)
: binary(state__, expr1, expr2)
{
this->kind__ = multiply_kind;
}
multiply::~multiply()
{
// not used
}
int multiply::isA(int kind) const
{
if(kind == multiply_kind)
return 1;
else
return binary::isA(kind);
}
const char *multiply::getKindName() const
{
return "multiply";
}
divide::divide(YYNODESTATE *state__, expression * expr1, expression * expr2)
: binary(state__, expr1, expr2)
{
this->kind__ = divide_kind;
}
divide::~divide()
{
// not used
}
int divide::isA(int kind) const
{
if(kind == divide_kind)
return 1;
else
return binary::isA(kind);
}
const char *divide::getKindName() const
{
return "divide";
}
power::power(YYNODESTATE *state__, expression * expr1, expression * expr2)
: binary(state__, expr1, expr2)
{
this->kind__ = power_kind;
}
power::~power()
{
// not used
}
void power::infer_type()
#line 69 "output18.tst"
{
expr1->infer_type();
expr2->infer_type();
if(expr2->type != int_type)
{
error("second sub-expression to `^' is not an integer");
}
type = expr1->type;
}
#line 445 "output.c"
int power::isA(int kind) const
{
if(kind == power_kind)
return 1;
else
return binary::isA(kind);
}
const char *power::getKindName() const
{
return "power";
}
negate::negate(YYNODESTATE *state__, expression * expr)
: unary(state__, expr)
{
this->kind__ = negate_kind;
}
negate::~negate()
{
// not used
}
int negate::isA(int kind) const
{
if(kind == negate_kind)
return 1;
else
return unary::isA(kind);
}
const char *negate::getKindName() const
{
return "negate";
}
--- NEW FILE ---
// test output logic for virtual operations, with C++ output
%option lang = "C++"
%option reentrant
%option gc_allocator
%node expression %abstract %typedef =
{
%nocreate type_code type;
}
%node binary expression %abstract =
{
expression *expr1;
expression *expr2;
}
%node unary expression %abstract =
{
expression *expr;
}
%node intnum expression =
{
int num;
}
%node plus binary
%node minus binary
%node multiply binary
%node divide binary
%node negate unary
%node power binary
%operation %virtual void infer_type(expression *this)
infer_type(binary)
{
type_code type1, type2;
expr1->infer_type();
type1 = expr1->type;
expr2->infer_type();
type2 = expr2->type;
if(type1 == float_type || type2 == float_type)
{
type = float_type;
}
else
{
type = int_type;
}
}
infer_type(unary)
{
expr->infer_type();
type = expr->type;
}
infer_type(intnum)
{
type = int_type;
}
infer_type(power)
{
expr1->infer_type();
expr2->infer_type();
if(expr2->type != int_type)
{
error("second sub-expression to `^' is not an integer");
}
type = expr1->type;
}
Index: test_list
===================================================================
RCS file: /cvsroot/dotgnu-pnet/treecc/tests/test_list,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** test_list 30 Dec 2002 21:54:14 -0000 1.4
--- test_list 4 Jul 2003 04:53:49 -0000 1.5
***************
*** 35,36 ****
--- 35,38 ----
test_output output15
test_output output16
+ test_output output17
+ test_output output18
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: treecc/tests output17.out,NONE,1.1 output17.tst,NONE,1.1 output18.out,NONE,1.1 output18.tst,NONE,1.1 test_list,1.4,1.5,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: treecc/etc c_gc_skel.c,NONE,1.1 c_gc_skel.h,NONE,1.1 cpp_gc_skel.cc,NONE,1.1 cpp_gc_skel.h,NONE,1.1 Makefile.am,1.2,1.3
- Next by Date:
[Dotgnu-pnet-commits] CVS: treecc ChangeLog,1.86,1.87 Makefile.am,1.5,1.6 context.c,1.5,1.6 gen_c.c,1.6,1.7 gen_cpp.c,1.5,1.6 info.h,1.10,1.11 options.c,1.8,1.9
- Previous by thread:
[Dotgnu-pnet-commits] CVS: treecc/etc c_gc_skel.c,NONE,1.1 c_gc_skel.h,NONE,1.1 cpp_gc_skel.cc,NONE,1.1 cpp_gc_skel.h,NONE,1.1 Makefile.am,1.2,1.3
- Next by thread:
[Dotgnu-pnet-commits] CVS: treecc ChangeLog,1.86,1.87 Makefile.am,1.5,1.6 context.c,1.5,1.6 gen_c.c,1.6,1.7 gen_cpp.c,1.5,1.6 info.h,1.10,1.11 options.c,1.8,1.9
- Index(es):