Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!hp4nl!tnoibbc!anita From: anita@tnoibbc.UUCP (Anita Eijs) Newsgroups: comp.unix.questions Subject: How to skip parts of the yacc-grammer ? Keywords: yacc, ifdef, endif, skip Message-ID: <2178@tnoibbc.UUCP> Date: 13 Nov 90 14:39:54 GMT Lines: 47 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@tnoibbc : PO-box 49 UUCP : ..!hp4nl!tnoibbc!anita : 2600 AA Delft DOMAIN : anita@ibbc.tno.nl : the Netherlands FAX : +31 15 843990