summaryrefslogtreecommitdiffstats
path: root/taccle/examples
diff options
context:
space:
mode:
Diffstat (limited to 'taccle/examples')
-rwxr-xr-xtaccle/examples/Makefile17
-rwxr-xr-xtaccle/examples/if_then_else.tac18
-rwxr-xr-xtaccle/examples/infix_calc.tac35
-rwxr-xr-xtaccle/examples/interactive_calculator.tac42
-rwxr-xr-xtaccle/examples/lalr_reduce_reduce.tac18
-rwxr-xr-xtaccle/examples/reduce_reduce.tac20
-rwxr-xr-xtaccle/examples/reduce_reduce2.tac15
-rwxr-xr-xtaccle/examples/shift_reduce.tac17
-rwxr-xr-xtaccle/examples/shift_reduce2.tac20
-rwxr-xr-xtaccle/examples/simple_calculator.tac36
-rwxr-xr-xtaccle/examples/simple_expressions.tac30
-rwxr-xr-xtaccle/examples/simple_grammar.tac27
-rwxr-xr-xtaccle/examples/simple_scanner.fcl16
13 files changed, 0 insertions, 311 deletions
diff --git a/taccle/examples/Makefile b/taccle/examples/Makefile
deleted file mode 100755
index 7235aea..0000000
--- a/taccle/examples/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.2 2004/09/29 16:23:28 tang Exp $
-
-TCL=tclsh
-FICKLE=~/fickle/fickle.tcl
-TACCLE=../taccle.tcl
-EXAMPLES=interactive_calculator.tcl simple_calculator.tcl infix_calc.tcl
-
-all: $(EXAMPLES) simple_scanner.tcl
-
-%.tcl: %.fcl
- $(TCL) $(FICKLE) $<
-
-%.tcl: %.tac
- $(TCL) $(TACCLE) -d -v -w $<
-
-clean:
- -rm -f *tcl *output
diff --git a/taccle/examples/if_then_else.tac b/taccle/examples/if_then_else.tac
deleted file mode 100755
index eee631a..0000000
--- a/taccle/examples/if_then_else.tac
+++ /dev/null
@@ -1,18 +0,0 @@
-# $Id: if_then_else.tac,v 1.1 2004/08/18 23:53:42 tang Exp $
-
-# The classical if/then/else ambiguity. taccle resolves this by
-# giving higher precedence to shifting else.
-#
-# References:
-# Dragon book, page 250
-# lex & yacc, pages 233-235
-
-%token IF ELSE TERMINAL
-
-%%
-
-stmt: IF '(' cond ')' stmt
- | IF '(' cond ')' stmt ELSE stmt
- | TERMINAL;
-
-cond: TERMINAL;
diff --git a/taccle/examples/infix_calc.tac b/taccle/examples/infix_calc.tac
deleted file mode 100755
index 95ef2ee..0000000
--- a/taccle/examples/infix_calc.tac
+++ /dev/null
@@ -1,35 +0,0 @@
-# $Id: infix_calc.tac,v 1.1 2004/09/29 16:23:28 tang Exp $
-
-# This example demonstrates how taccle handles operator precedence.
-# The code is shamelessly borrowed from the GNU Bison info manual.
-
-# taccle Declarations
-%token ID NEWLINE
-%left '-' '+'
-%left '*' '/'
-%left NEG # negation--unary minus
-%right '^' # exponentiation
-
-# Grammar follows
-%%
-input: # empty string
- | input line
-;
-
-line: NEWLINE
- | exp NEWLINE { puts [format "\t%.10g" $1] }
-;
-
-exp: ID { set _ $1 }
- | exp '+' exp { set _ [expr {$1 + $3}] }
- | exp '-' exp { set _ [expr {$1 - $3}] }
- | exp '*' exp { set _ [expr {$1 * $3}] }
- | exp '/' exp { set _ [expr {$1 / $3}] }
- | '-' exp %prec NEG { set _ [expr {-1.0 * $2}] }
- | exp '^' exp { set _ [expr {pow($1, $3)}] }
- | '(' exp ')' { set _ $2 }
-;
-%%
-
-source simple_scanner.tcl
-yyparse
diff --git a/taccle/examples/interactive_calculator.tac b/taccle/examples/interactive_calculator.tac
deleted file mode 100755
index ac8a3ba..0000000
--- a/taccle/examples/interactive_calculator.tac
+++ /dev/null
@@ -1,42 +0,0 @@
-# $Id: interactive_calculator.tac,v 1.2 2004/09/08 21:38:44 tang Exp $
-
-# This example expands the simple calculator to be interactive from
-# the command line. Note the use of an empty rule (i.e., epsilon
-# transition). Also featured are the error token and error recovery.
-
-%{
-#!/usr/bin/tclsh
-
-%}
-
-%token ID NEWLINE
-
-%%
-
-start: line NEWLINE start
- | line
- ;
-
-line: E { puts " = $1" }
- | error { puts " -- error" }
- | # empty
- ;
-
-E: E '+' T { set _ [expr {$1 + $3}] }
- | E '-' T { set _ [expr {$1 - $3}] }
- | T
- ;
-
-T: T '*' F { set _ [expr {$1 * $3}] }
- | T '/' F { set _ [expr {$1 / $3}] }
- | F
- ;
-
-F: '(' E ')' { set _ $2 }
- | ID { set _ $::yylval }
- ;
-
-%%
-
-source simple_scanner.tcl
-yyparse
diff --git a/taccle/examples/lalr_reduce_reduce.tac b/taccle/examples/lalr_reduce_reduce.tac
deleted file mode 100755
index fb7e493..0000000
--- a/taccle/examples/lalr_reduce_reduce.tac
+++ /dev/null
@@ -1,18 +0,0 @@
-# $Id: lalr_reduce_reduce.tac,v 1.1 2004/08/18 23:53:42 tang Exp $
-
-# Below illustrates a grammar that is ambiguous by an LALR(1) parser
-# but not an LR(1). There is a reduce/reduce conflict given a viable
-# prefix ac. taccle resolves this by giving precedence to the first
-# listed rule (A -> c).
-#
-# Reference:
-# Dragon book, page 238
-
-%token a b c d e
-
-%%
-
-S: a A d | b B d | a B e | b A e ;
-
-A: c ;
-B: c ;
diff --git a/taccle/examples/reduce_reduce.tac b/taccle/examples/reduce_reduce.tac
deleted file mode 100755
index 4de6556..0000000
--- a/taccle/examples/reduce_reduce.tac
+++ /dev/null
@@ -1,20 +0,0 @@
-# $Id: reduce_reduce.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-# This is an example of where a lookahead of just one symbol is
-# insufficient. taccle finds a reduce/reduce conflict and resolves it
-# by giving precedence to the first rule (cart_animal -> horse).
-#
-# Reference:
-# lex & yacc, page 55
-
-%token and cart plow horse goat ox
-
-%%
-
-phrase: cart_animal and cart
- | work_animal and plow
- ;
-
-cart_animal: horse | goat ;
-
-work_animal: horse | ox ;
diff --git a/taccle/examples/reduce_reduce2.tac b/taccle/examples/reduce_reduce2.tac
deleted file mode 100755
index 53c6d3b..0000000
--- a/taccle/examples/reduce_reduce2.tac
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id: reduce_reduce2.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-# Here is another reduce/reduce conflict.
-#
-# Reference:
-# lex & yacc, page 225
-
-%token A B C Z
-
-%%
-
-start: A B x Z | y Z;
-
-x: C;
-y: A B C;
diff --git a/taccle/examples/shift_reduce.tac b/taccle/examples/shift_reduce.tac
deleted file mode 100755
index 8905e26..0000000
--- a/taccle/examples/shift_reduce.tac
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: shift_reduce.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-# This is an example of a shift/reduce conflict. Eventually I will
-# add operator precedence and associativity, but for now taccle simply
-# gives higher precedence to shifts.
-#
-# Reference:
-# lex & yacc, pages 229-230 and 236
-
-%token TERMINAL
-
-%%
-
-expr: TERMINAL
- | expr '+' expr
- | expr '-' expr
- | expr '*' expr ;
diff --git a/taccle/examples/shift_reduce2.tac b/taccle/examples/shift_reduce2.tac
deleted file mode 100755
index c3ad0d3..0000000
--- a/taccle/examples/shift_reduce2.tac
+++ /dev/null
@@ -1,20 +0,0 @@
-# $Id: shift_reduce2.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-# Here is one final shift/reduce conflict. taccles resolves the
-# problem by giving precedence to a shift.
-#
-# Reference:
-# lex & yacc, pages 226-227
-
-%token A R
-
-%%
-
-start: x1
- | x2
- | y R;
-
-x1: A R;
-x2: A z;
-y: A;
-z: R;
diff --git a/taccle/examples/simple_calculator.tac b/taccle/examples/simple_calculator.tac
deleted file mode 100755
index ea104aa..0000000
--- a/taccle/examples/simple_calculator.tac
+++ /dev/null
@@ -1,36 +0,0 @@
-# $Id: simple_calculator.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-# This example demonstrates symbol and synthesized values.
-
-%{
-#!/usr/bin/tclsh
-
-%}
-
-%token ID NEWLINE
-%start start
-
-%%
-
-start: E NEWLINE { puts "Result is $1" }
- | E { puts "Result is $1" }
- ;
-
-E: E '+' T { set _ [expr {$1 + $3}] }
- | E '-' T { set _ [expr {$1 - $3}] }
- | T
- ;
-
-T: T '*' F { set _ [expr {$1 * $3}] }
- | T '/' F { set _ [expr {$1 / $3}] }
- | F
- ;
-
-F: '(' E ')' { set _ $2 }
- | ID { set _ $::yylval }
- ;
-
-%%
-
-source simple_scanner.tcl
-yyparse
diff --git a/taccle/examples/simple_expressions.tac b/taccle/examples/simple_expressions.tac
deleted file mode 100755
index 7cc1f58..0000000
--- a/taccle/examples/simple_expressions.tac
+++ /dev/null
@@ -1,30 +0,0 @@
-# $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
diff --git a/taccle/examples/simple_grammar.tac b/taccle/examples/simple_grammar.tac
deleted file mode 100755
index ea354d9..0000000
--- a/taccle/examples/simple_grammar.tac
+++ /dev/null
@@ -1,27 +0,0 @@
-# $Id: simple_grammar.tac,v 1.1 2004/08/18 23:53:43 tang Exp $
-
-%{
-
-source simple_scanner.tcl
-
-%}
-
-%token ID
-
-%%
-
-E: E '+' T
- | T
- ;
-
-T: T '*' F
- | F
- ;
-
-F: '(' E ')'
- | ID
- ;
-
-%%
-
-yyparse
diff --git a/taccle/examples/simple_scanner.fcl b/taccle/examples/simple_scanner.fcl
deleted file mode 100755
index 99ff67f..0000000
--- a/taccle/examples/simple_scanner.fcl
+++ /dev/null
@@ -1,16 +0,0 @@
-# $Id: simple_scanner.fcl,v 1.2 2004/08/18 23:55:31 tang Exp $
-
-%{
-source "simple_calculator.tab.tcl"
-%}
-
-%option interactive
-
-number [0-9]+
-
-%%
-
-{number} { set ::yylval $yytext; return $::ID }
-\n { return $::NEWLINE }
-\s # ignore whitespace
-. { set ::yylval $yytext; return $yytext }