[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Examples of Bison files
From: |
Hans Aberg |
Subject: |
Re: Examples of Bison files |
Date: |
Sun, 2 Dec 2001 12:28:51 +0100 |
>I create some kind of grammar (BNF) to describe geometrical
>construction. Bison understand this grammar, but I found problem how
>to add action to all of expressions.
>So, I'm looking for every kind of examples. Maybe it helps me better
>understand Bison.
I send you an example of a simple C++ calculator (next email), which I
think I published in this group some time ago. The Bison manual has more
similar examples.
Each terminal or nonterminal has a $ value. For example
expr: expr '+' expr { $$.value = $1.value + $3.value }
means: Add value of first and third token (= terminal), and assign that to
the value of the left hand side nonterminal (= the rule value, as the
grammar is context free).
Hans Aberg