-
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.
FL is Rascal: now with abstract syntax
- Loading branch information
1 parent
a8bb16a
commit 35847a7
Showing
5 changed files
with
55 additions
and
31 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,4 @@ | ||
build: | ||
|
||
test: | ||
cd src && java -Xmx1G -Xss32m -jar ../../../../download/rascal.jar FL ../../shared/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,13 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module Abstract | ||
|
||
data FLPrg = prg(list[FLFun]); | ||
data FLFun = fun(str f, list[str] args, FLExpr body); | ||
data FLExpr | ||
= binary(FLExpr e1, FLOp op, FLExpr e2) | ||
| apply(str f, list[FLExpr] vargs) | ||
| ifThenElse(FLExpr c, FLExpr t, FLExpr e) | ||
| argument(str a) | ||
| literal(int i) | ||
; | ||
data FLOp = minus() | plus() | equal(); |
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 |
---|---|---|
@@ -1,37 +1,24 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module Concrete | ||
|
||
import IO; | ||
import ParseTree; | ||
|
||
syntax Program = Function+ LO; | ||
syntax Function = Name Name+ "=" Expr Newline ; | ||
syntax Expr = | ||
binary: Expr Ops Expr | ||
syntax Program = prg: {Function "\n"}+ "\n"*; | ||
syntax Function = fun: Name Name+ "=" Expr ; | ||
syntax Expr | ||
= binary: Expr Ops Expr | ||
| apply: Name Expr+ | ||
| ifThenElse: "if" Expr "then" Expr "else" Expr | ||
| "(" Expr ")" | ||
| bracket "(" Expr ")" | ||
| argument: Name | ||
| literal: Int ; | ||
syntax Ops = | ||
minus: "-" | ||
| literal: Int | ||
; | ||
syntax Ops | ||
= minus: "-" | ||
| plus: "+" | ||
| equal: "==" ; | ||
| equal: "==" | ||
; | ||
|
||
lexical Name = [a-z]+ !>> [a-z] ; | ||
lexical Int = [0] | [1-9][0-9]* !>> [0-9] ; | ||
lexical Newline = "\n" ; | ||
layout LO = [\ \t]* ; | ||
|
||
public void main(list[str] args) | ||
{ | ||
loc src = |cwd:///|+args[0]; | ||
do(src); | ||
} | ||
|
||
public void main() = do(|home:///projects/slps/topics/fl/shared/factorial.txt|); | ||
|
||
void do(loc src) | ||
{ | ||
parse(#Program,src); | ||
println("Done."); | ||
} | ||
layout LO = [\ \t]* !>> [\ \t]; | ||
keyword FLKwd = "if" | "then" | "else" ; |
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,24 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module FL | ||
|
||
import Concrete; | ||
import Abstract; | ||
import IO; | ||
import ParseTree; | ||
|
||
public void main(list[str] args) | ||
{ | ||
loc src = |cwd:///|+args[0]; | ||
do(src); | ||
} | ||
|
||
public void main() = do(|home:///projects/slps/topics/fl/shared/factorial.txt|); | ||
|
||
void do(loc src) | ||
{ | ||
println("The Factorial Language: Rascal implementation."); | ||
c = parse(#Program,src); | ||
println("Parsing: done."); | ||
a = implode(#FLPrg,c); | ||
println("Imploding: done."); | ||
} |
This file was deleted.
Oops, something went wrong.