Skip to content

Commit

Permalink
better parser
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@658 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Jul 6, 2009
1 parent 901f622 commit c861ed4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 4 additions & 17 deletions topics/fl/txl/FL.Txl
Expand Up @@ -13,8 +13,10 @@ define expression
[expression] [op] [expression]
| [id] [expression+]
| if [expression] then [expression] else [expression]
| [expression] == [expression]
| [primary]
| [number]
| [id]
| ( [expression] )

end define

define op
Expand All @@ -23,21 +25,13 @@ define op
| ==
end define

define primary
[number]
| [id]
| ( [expression] )
end define


% Part 2. Transformation rules
rule main
replace [expression]
E [expression]
construct NewE [expression]
E [resolveAddition]
[resolveSubtraction]
[resolveBracketedExpressions]
where not
NewE [= E]
by
Expand All @@ -58,10 +52,3 @@ rule resolveSubtraction
N1 [- N2]
end rule

rule resolveBracketedExpressions
replace [primary]
( N [number] )
by
N
end rule

2 changes: 2 additions & 0 deletions topics/fl/txl/Makefile
@@ -1,3 +1,5 @@
test:
cp ../shared/factorial.txt factorial.fl
/bin/echo -n "evaluator x = " >>factorial.fl
cat ../shared/fac5.txt >> factorial.fl
txl -newline factorial.fl

0 comments on commit c861ed4

Please sign in to comment.