How to skip parts of the yacc-grammer ?

Anita Eijs anita at tnoibbc.UUCP
Wed Nov 14 01:39:54 AEST 1990


I am writing a parser/compiler for the Data Definition Language Express
using lex and yacc.
Some of our partners only want to use a subset of Express, they want to use
a parser which only allows the definition of that subset.

For example : An attribute can be of an integer-, real-, list or array-type,
within the subset only an integer- and a real-type are allowed. So the
following yacc-grammar :

	attribute_type:
		integer_type
		| real_type
		| list_type
		| array_type
		;

should be changed for the subset to :

	attribute_type:
		integer_type
		| real_type
		;

I would like to have the complete yacc-grammar in one yacc-file, so I tried
to use the #ifdef ... #endif constructs and compile with the option -DSUBSET.

	attribute_type:
		integer_type
		| real_type
#ifndef SUBSET
		| list_type
		| array_type
#endif
		;

The yacc-program isn't able to convert this grammar. Within the yacc-grammar
it is not allowed to have those constructs.

Can anybody help me with this problem ?

Thanks in advance !
-- 
Anita Eijs : TNO - IBBC                     USENET : anita at tnoibbc
           : PO-box 49                      UUCP   : ..!hp4nl!tnoibbc!anita
           : 2600 AA  Delft                 DOMAIN : anita at ibbc.tno.nl
           : the Netherlands                FAX    : +31 15 843990



More information about the Comp.unix.questions mailing list