Grammar for Boolean Equations

Could anyone show me a grammar for boolean equation with 3 variables x,y.zthat i could use to help build a parser. thankspodger
[155 byte] By [podger_cora] at [2007-10-1 7:21:56]
# 1

Equation := '(' 'equal' Expression Expression ')';

Expression := Var | AndEx | OrEx | NotEx;

NotEx := '(' 'not' Expression ')';

AndEx := '(' 'and' Expression+ ')';

OrEx := '(' 'or' Expression+ ')';

Var := 'x' | 'y' | 'z';

is probably the easiest complete one to build a parser for; if you want some other language (eg infix operators) then you need a more complicated parser; essentially the grammar morphs to

Equation := DisEx 'equal' DisEx;

DisEx := DisTerm ( 'or' DisTerm) *;

DisTerm := Var | ConEx | NotEx;

Var := 'x' | 'y' | 'z';

ConEx := ConTerm ( 'and' ConTerm ) +;

ConTerm := ExTerm | '(' Expression ')';

NotEx := 'not' ConTerm;

Which is harder to write a parser for.

pm_kirkhama at 2007-7-9 18:31:58 > top of Java-index,Other Topics,Algorithms...
# 2
could this be used for an equation of the type2x-3y+4z
podger_cora at 2007-7-9 18:31:58 > top of Java-index,Other Topics,Algorithms...
# 3
> could this be used for an equation of the type> 2x-3y+4zAnd which of the operators in the above are boolean?Perhaps you meant to ask about binary expressions?
jschella at 2007-7-9 18:31:58 > top of Java-index,Other Topics,Algorithms...
# 4
sorry my mistake i meant an equation of the type2x - 3y = 3y + x
podger_cora at 2007-7-9 18:31:58 > top of Java-index,Other Topics,Algorithms...
# 5

> sorry my mistake i meant an equation of the type

> 2x - 3y = 3y + x

The term "boolean" in this context means that the elements in your expression are all booleans (i.e. true/false). 2 and 3 are certaintly not true/false valued. What your looking for is a parser for simple mathematical expressions. I'm sure you can find at least one example by searching the forums, or google will give plenty of examples.

Good luck.

RadcliffePikea at 2007-7-9 18:31:58 > top of Java-index,Other Topics,Algorithms...