-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quick Rascal implementation of FL, just the parser
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@1160 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
5ca8708
commit a5dd4fe
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module FL | ||
|
||
import IO; | ||
import ParseTree; | ||
|
||
syntax Program = Function+ LO; | ||
syntax Function = Name Name+ "=" Expr ";" ; | ||
syntax Expr = | ||
binary: Expr Ops Expr | ||
| apply: Name Expr+ | ||
| ifThenElse: "if" Expr "then" Expr "else" Expr | ||
| "(" Expr ")" | ||
| argument: Name | ||
| literal: Int ; | ||
lexical Ops = | ||
minus: "-" | ||
| plus: "+" | ||
| equal: "==" ; | ||
lexical Name = [a-z]+ !>> [a-z] ; | ||
lexical Int = [0] | [1-9][0-9]* !>> [0-9] ; | ||
layout LO = [\ \t\n\r]? ; | ||
|
||
public void main(list[str] args) | ||
{ | ||
loc src = |cwd:///|+args[0]; | ||
parse(#Program,src); | ||
println("Done."); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build: | ||
|
||
test: | ||
java -jar ../../../download/rascal.jar FL.rsc factorial.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mult n m = if (n==0) then 0 else (m + (mult (n - 1) m)); | ||
fac n = if (n==0) then 1 else (mult n (fac (n - 1))); |