summaryrefslogtreecommitdiffstats
path: root/taccle/examples/simple_expressions.tac
blob: 7cc1f58f372b8dae73ab95515e0d7d06f54a0deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# $Id: simple_expressions.tac,v 1.1 2004/08/18 23:53:43 tang Exp $

# This examples takes simple_grammar and adds actions to each rule.

%{
#!/usr/bin/tclsh

%}

%token ID
%start E

%%

E: E '+' T    { puts "E + T" }
 | T          { puts "T" }
 ;

T: T '*' F    { puts "T * F" }
 | F          { puts "F" }
 ;
 
F: '(' E ')'  { puts "(E)" }
 | ID         { puts "id" }
 ;
 
%%

source simple_scanner.tcl
yyparse