I have attached the latest listing of the program in question. It is actually parse.y but had to be uploaded as parse.txt. When I run
Bison now, then the messages I get from that are...
parse.y: warning: 8 useless nonterminals and 30 useless rules
parse.y:52.1-7: fatal error: start symbol grammar does not derive any
sentence. The 2nd message is the most crucial at the moment.

I believe ( could be wrong) that The particular code it refers to is...
%%
grammar: domains
constants
predicates
;

My intention is that it reads a set of domains...
typically each one is to a line of a format...
D0 11 0 10 // domainName, number_of_values, floor_value, ceil_value
...
Then reads a set of constants...
typically each one to a line of a format...
X0 D0 9

Then reads and processes a set of predicates, each one to a line, which
may appear as...
or(lt(mul(X0,X1),X2),ge(abs(sub(X3,X4)),X5))

However, I have no precedent or pro-forma for such as 'grammar' above. I
think that the domains constants predicates sequence I've written will
read all the
domains, then all the constants then all the predicates without allowing
any regression through any of them (eg a domain in the constants).

That the start symbol 'grammar' cannot derive any sentence only suggests
to me that the grammar high level nonTerminal cannot access it's
subsidiary terminals and non-terminals, but the exact cause is not yet
clear to me.

The classic example such as p75 of lex & yacc...[1995 Levine et al]
statement_list: statement '\n'
statement_list statement '\n'
;
...doesn't shed much light on my codes attached below, where I must read a
group of domains, followed by a group of constants, followed by a group of
predicates.

I'm not exactly sure what the error means, but I believe you mean

grammar:  
	  domains	
	  constants 	
	  predicates
	;

or

grammar:  
	  domains	
	 | grammar constants 	
	 | grammar predicates
	;

depending upon if you want just one set of constants followed by one set of predicates, or just one set of domains followed by any number of constants and predicates.

I'm not exactly sure what the error means, but I believe you mean

grammar:  
	  domains	
	  constants 	
	  predicates
	;

or

grammar:  
	  domains	
	 | grammar constants 	
	 | grammar predicates
	;

depending upon if you want just one set of constants followed by one set of predicates, or just one set of domains followed by any number of constants and predicates.

Thanks for answering Marc,
Firstly a list of uninterrupted domain data are read,
then a list of uninterrupted constants are read,
then a list of uninterrupted predicates are read,
the formats for each above are as described in the initial message.
None of the domains or constants or predicates can appear out of place in the described sequence described in this message above.

I understand the Yacc code you wrote, but am surprised that the Bison code described after could be different. The Yacc code FORCES sequence, the Bison code would appear to not do so because of the |. It looks to me as though the Bison code could be any sequence of- all domains or all constants or all predicates with no forced sequence.

The requirement I am trying to fulfill is just one set of domains, then THEY'RE finished, then one set of constants, then THEY'RE finished, then the set of predicates, at completion of which is the end of the program.

Thanks, Joe, Cork, Ireland

The yacc/bison language varianced was just testing if daniweb put any syntax highlighting for either language.

Yes, according to your requirements you want the "yacc" one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.