Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Jared M.F. and Karol S. FiM++ Merging #6

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all:
mkdir -p target
scalac -d target src/stasiak/karol/fimpp/*
cd target && jar cfe ../bin/fimpp.jar stasiak.karol.fimpp.Main stasiak
#mkdir -p target
scalac -d bin/fimpp.jar src/stasiak/karol/fimpp/*
#cd target && fastjar -cvf ../bin/fimpp.jar stasiak/karol/fimpp/

clean:
rm -r target
#clean:
# rm -r target
2 changes: 1 addition & 1 deletion bin/fimpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
DIR=`dirname "$0"`
java -cp "$DIR/scala-library.jar:$DIR/fimpp.jar" stasiak.karol.fimpp.Main "$@"
java -cp "$DIR/scala-library.jar:$DIR/fimpp.jar:$DIR/scala-parser-combinators.jar" stasiak.karol.fimpp.Mane "$@"
2 changes: 1 addition & 1 deletion bin/fimpp.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -cp "%~dp0\scala-library.jar;%~dp0\fimpp.jar" stasiak.karol.fimpp.Main "%1"
java -cp "%~dp0\scala-library.jar;%~dp0\fimpp.jar" stasiak.karol.fimpp.Mane "%1"
Binary file modified bin/scala-library.jar
Binary file not shown.
Binary file added bin/scala-parser-combinators.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/factorials.fimpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Dear Princess Celestia: Letter about Factorials.

I learned about the factorial with Spike:
By the way, this function will return a factorial of Spike's number.

Did you know that Sweetie Belle likes Spike?
I did this while Spike had more than the number one:
Spike got one fewer.
Sweetie Belle did the product of Sweetie Belle and Spike!
That's what I did.
That's about the factorial with Sweetie Belle!

Today I learned:
Did you know that Rarity likes the number one?
I did this 20 times:
Twilight Sparkle did the factorial of Rarity.
I wrote: Twilight Sparkle!
Rarity got one more.
That's what I did!
Your faithful student, Jared MF.
22 changes: 22 additions & 0 deletions examples/fourth_power.fimpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Dear Princess Celestia: Letter about the Fourth Power.

I learned about the fourth power with Twilight Sparkle:
Did you know Flash Sentry likes Twilight Sparkle?
Flash Sentry did the product of Twilight Sparkle and Flash Sentry!
Spike did the product of Twilight Sparkle and Flash Sentry!
Princess Luna did the product of Twilight Sparkle and Spike!

Did you know Twilight Sparkle likes the number zero?
Did you know Flash Sentry likes Twilight Sparkle?
Did you know Spike likes Twilight Sparkle?
That's about the fourth power with Princess Luna.

Today I learned:
Did you know Applejack likes the number two?

I did this 20 times:
Pinkie Pie did the fourth power of Applejack.
I wrote: Pinkie Pie!
Applejack got one more.
That's what I did!
Your faithful student, Jared MF.
34 changes: 34 additions & 0 deletions examples/multiples.fimpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Dear Princess Celestia: Letter about Multiples.

I learned about multiples with Princess Luna:
Did you know Rarity likes the number one?
Did you know Spike likes Rarity?
Did you know Twilight Sparkle likes Spike?

Spike got one more, because he is Twilight Sparkle's sidekick.
Twilight Sparkle got two more, because she is the leader of the Mane 6.

Did you know Discord likes Rarity, Spike, and Twilight Sparkle?
Discord made the dictionary of Discord!

I did this while Princess Luna was not equal to 0:
I wrote: Discord!
On the first page of Discord I read about Rarity.
Rarity got one more.
On the first page of Discord I wrote what I knew about Rarity.

On the second page of Discord I read about Spike.
Spike got two more, because he is Twilight Sparkle's sidekick.
On the second page of Discord I wrote what I knew about Spike.

On the third page of Discord I read about Twilight Sparkle.
Twilight Sparkle got three more, because she is the leader of the Mane 6.
On the third page of Discord I wrote what I knew about Twilight Sparkle.

Princess Luna got one fewer.
That's what I did!
That's about multiples.

Today I learned how this works:
I made multiples of 200!
Your faithful student, Jared MF.
72 changes: 72 additions & 0 deletions examples/odd_even.fimpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Dear Princess Celestia: Against All Odds and Evens:

I learned about sorting odds with Twilight Sparkle:
By the way, this function checks for all the odd numbers, such as 1, 3, and 5.

Did you know Rarity likes the number one?
Did you know Spike likes Rarity?
I found a book titled Sweetie Belle today, because she will hold the odd numbers.

On the first page of Twilight Sparkle I read about Tom Dan, because he might hold the current odd number.
On the first page of Sweetie Belle I noted about Tom Dan, because that's where the odd numbers go.
Rarity got two more. Spike got one more.
On the page numbered by Rarity of Twilight Sparkle I read about Tom Dan.
I did this while Tom Dan was something:
On the page numbered by Spike of Sweetie Belle I noted about Tom Dan.
Rarity got two more. Spike got one more.
On the page numbered by Rarity of Twilight Sparkle I read about Tom Dan.
That's what I did!
That's about sorting odds with Sweetie Belle.

I learned about sorting evens with Fluttershy:
By the way, this function checks for all the even numbers, such as 2, 4, and 6.

Did you know Rainbow Dash likes the number one?
Did you know Scootaloo likes Rainbow Dash?
Rainbow Dash got one more.
I found a book titled Spitfire today, because she will hold the even numbers.

On the second page of Fluttershy I read about Tank, because he might hold the current even number.
On the first page of Spitfire I noted about Tank, because that's where the even numbers go.
Rainbow Dash got two more. Scootaloo got one more.
On the page numbered by Rainbow Dash of Fluttershy I read about Tank.
I did this while Tank was something:
On the page numbered by Scootaloo of Spitfire I noted about Tank.
Rainbow Dash got two more. Scootaloo got one more.
On the page numbered by Rainbow Dash of Fluttershy I read about Tank.
That's what I did!
That's about sorting evens with Spitfire.

I learned about viewing numbers with Applejack.
By the way, this function checks for all the numbers instead of nothing.

Did you know Pinkie Pie likes the number one?
I found a book titled Apple Bloom today, because she will hold ALL of Appljack's numbers, and she is her sister.

On the first page of Applejack I read about Big Mac, because he will hold the current number.
On the first page of Apple Bloom I noted about Big Mac, because of what I already mentioned about Apple Bloom!
Pinkie Pie got one more.
On the page numbered by Pinkie Pie of Applejack I read about Big Mac.
I did this while Big Mac was somepony:
On the page numbered by Pinkie Pie of Apple Bloom I noted about Big Mac.
Pinkie Pie got one more.
On the page numbered by Pinkie Pie of Applejack I read about Big Mac.
That's what I did!
That's about viewing numbers with Apple Bloom.

Today I learned about sorting:
Did you know Twilight Sparkle likes 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, nothing, and nothing?
Sunset Shimmer did the dictionary of Twilight Sparkle!
Princess Cadance did viewing numbers of Sunset Shimmer.

I wrote: "All numbers: 'Princess Cadance'", because she will show ALL the numbers.
I sang new line.

Snips did sorting odds of Sunset Shimmer.
Snails did sorting evens of Sunset Shimmer.

I wrote: "Odd numbers: 'Snips'", because he will show all the odd numbers.
I wrote: "Even numbers: 'Snails'", because he will show all the even numbers.

By the way, that has been my odds and evens program.
Your faithful student, Jared MF.
42 changes: 42 additions & 0 deletions examples/squared_cubed.fimpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Dear Princess Celestia: Squared and Cubed.

I learned about square cube numbers with Queen Chrysalis:
Did you know Rarity likes the number one?
Did you know Spike likes Rarity?
Did you know Twilight Sparkle likes Spike?
Did you know Discord likes Rarity, Spike, and Twilight Sparkle?

Fluffle Puff did the dictionary of Discord.
I did this while Queen Chrysalis was not equal to zero:
I wrote: Fluffle Puff!

On the first page of Fluffle Puff I read about Rarity.
On the second page of Fluffle Puff I read about Spike.
On the third page of Fluffle Puff I read about Twilight Sparkle.
Rarity got one more.
Did you know Spike likes Rarity?
Did you know Twilight Sparkle likes Spike?
I did this once:
Did you know Sweetie Belle likes Spike?
Sweetie Belle did the product of Spike and Sweetie Belle!
Spike did the difference of Spike and Sweetie Belle.
That's what I did!
I did this once:
Did you know Flash Sentry likes Twilight Sparkle?
Flash Sentry did the product of Twilight Sparkle and Flash Sentry!
Princess Luna did the product of Twilight Sparkle and Flash Sentry!
Did you know Twilight Sparkle likes the number zero?
Did you know Flash Sentry likes Twilight Sparkle, because I said that earlier?
That's what I did.
On the first page of Fluffle Puff I noted about Rarity.
On the second page of Fluffle Puff I noted about Sweetie Belle.
On the third page of Fluffle Puff I noted about Princess Luna.

Queen Chrysalis got one fewer.
That's what I did.
That's about square cube numbers.

Today I learned:
I made square cube numbers of the number 200.
By the way, that is how square numbers and cube numbers are made.
Your faithful student, Jared MF.
10 changes: 5 additions & 5 deletions src/stasiak/karol/fimpp/ErrorMessageProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ trait ErrorMessageProvider {
object Trollestia extends ErrorMessageProvider {
def syntaxError(functionName: String) = "Now say, do you like mmm-syntax errors? You have one in function ‘"+
functionName+"’ after all. No? So let me get it straight: you're a mmm-biatch that does not like syntax errors. " +
"That's good, because there are no syntax errors... ON THE MOOOON!"
"That's good, because there are no syntax errors... ON THE MOOOON! -Princess Celestia"
def mismatchedFunctionNameInFooter(expected: String, found: String) = "This function is a changeling! At the beginning it was named ‘" +
expected + "’, and now it's ‘" + found + "’!"
def unknownError = "To the moon with that code!"
def invalidIdentifier(id: String) = "‘"+id.capitalize+"’ ain't no pony I've heard of. Do they have tea parties with ‘"+id.capitalize+"’?"
}
expected + "’, and now it's ‘" + found + "’! -Princess Celestia"
def unknownError = "To the moon with that code! -Princess Celestia and Princess Luna"
def invalidIdentifier(id: String) = "Mmm-‘"+id.capitalize+"’... I've never heard of such pony, you know. Do they have tea parties with ‘"+id.capitalize+"’? -Princess Celestia"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ import io.Source
* Time: 11:26
* To change this template use File | Settings | File Templates.
*/
object Main {
object Mane {
def main(args: Array[String]){
//TODO: flags
args.length match {
case 0 =>
println("To run a FIM++ program, pass it as the first argument to this program.")
case 1=>
println("parsing: "+args(0))
val program = Source.fromFile(args(0)).getLines().mkString("\n")
val parsed = FimppParser.parseAll(FimppParser.module, program)
if (parsed.successful) {
println("interpreting: "+args(0))
parsed.get.run()
if args(0).endsWith (".fimpp") {
println("parsing: "+args(0))
val program = Source.fromFile(args(0)).getLines().mkString("\n")
val parsed = FimppParser.parseAll(FimppParser.module, program)
if (parsed.successful) {
println("interpreting: "+args(0))
parsed.get.run()
}
else println(parsed)
}
else println(parsed)
else println("That ain't no program I've ever heard of. TO THE MOOOOOOON!!! -Princess Luna")
case _ =>
println("Hold your horses! One file at a time, please!")
}
Expand Down
8 changes: 4 additions & 4 deletions syntax/Program structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ FIM++ program structure

FIM++ programs can have one of two structures:

* Main function contains functions inside (wrapped style).
* 'Mane' function contains functions inside (wrapped style).

* Functions precede the main function, and the main function, being the last one in the code, contains statements (C style).
* Functions precede the 'mane' function, and the 'mane' function, being the last one in the code, contains statements (C style).

In all examples below, colons can be replaced with full stops, except after the word Celestia. Parts in braces {...} are optional.

Wrapped style:
-------------

Execution of the program will start from the function that has the same name as the main function. It will be called with no arguments.
Execution of the program will start from the function that has the same name as the 'mane' function. It will be called with no arguments.

Dear Princess Celestia: <module identifier> :

Expand All @@ -25,7 +25,7 @@ Execution of the program will start from the function that has the same name as
C style
------

Execution of the program will start from the main function.
Execution of the program will start from the 'mane' function.

Dear Princess Celestia: <module identifier> :

Expand Down