Skip to content

Commit

Permalink
Add Senpai
Browse files Browse the repository at this point in the history
  • Loading branch information
Dash-Lambda committed Oct 17, 2021
1 parent caf83f8 commit 1670229
Show file tree
Hide file tree
Showing 21 changed files with 765 additions and 130 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ Current native language support (mostly in chronological order):
27. [LazyK](https://esolangs.org/wiki/Lazy_K)
28. [ALPL](https://esolangs.org/wiki/ALPL)
29. [LazyBird](https://esolangs.org/wiki/Lazy_Bird)
30. Scala
30. [Senpai](https://esolangs.org/wiki/Senpai) (Currently missing module import command)
31. Scala

### Current features:
* Run programs from text files
Expand Down
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ThisBuild / scalaVersion := "2.13.3"
ThisBuild / version := "2.5.5"
ThisBuild / version := "2.6.0"
ThisBuild / organization := "com.github.dashlambda"
ThisBuild / organizationName := "dashlambda"

Expand All @@ -22,5 +22,6 @@ lazy val root = (project in file("."))
"org.scalactic" %% "scalactic" % "3.2.9",
"org.scalatest" %% "scalatest" % "3.2.9" % "test"),
assembly / assemblyJarName := s"Eso-${version.value}.jar",
assembly / mainClass := Some("ui.NonPersistent")
assembly / mainClass := Some("ui.NonPersistent"),
assembly / assemblyOption ~= { _.withCacheOutput(false) }
)
17 changes: 13 additions & 4 deletions esoTestLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ FracTran++
FracTran
- should run primes.ft correctly
- should return a referentially transparent function for primes.ft
SenpaiSpec:
Senpai
- should run hworld.senpai correctly
- should run cat.senpai correctly
- should run truthmachine0.senpai correctly
- should run truthmachine1.senpai correctly
- should run fizzbuzz.senpai correctly
- should run quine.senpai correctly
- should run beer.senpai correctly
SlashesSpec:
///
- should run hworld.slash correctly
Expand Down Expand Up @@ -450,8 +459,8 @@ Metatape
- should run bitWidth.mt correctly
- should return a referentially transparent function for hworld.mt
- should return a referentially transparent function for bitWidth.mt
Run completed in 1 minute, 27 seconds.
Total number of tests run: 286
Suites: completed 81, aborted 0
Tests: succeeded 286, failed 0, canceled 0, ignored 0, pending 0
Run completed in 1 minute, 46 seconds.
Total number of tests run: 293
Suites: completed 82, aborted 0
Tests: succeeded 293, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
2 changes: 1 addition & 1 deletion fileAssoc.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"alpl":"ALPL","b":"BrainFuck","b93":"Befunge-93","b98":"Befunge-98","cpp":"C++","df":"Deadfish","emm":"Emmental","fl":"FlufflePuff","ft":"FracTran","ftp":"FracTran++","glo":"Glypho","glos":"GlyphoShorthand","grs":"Grass","lazy":"LazyK","lzb":"LazyBird","mt":"Metatape","names":["ftp","lazy","slash","th","df","b98","wl","b93","ws","pld","plts","grs","path","mt","pdp","cpp","lzb","glo","nul","glos","b","emm","fl","vol","alpl","unl","scala","ft","ook","wd","wsa","snusp"],"nul":"NULL","ook":"Ook","path":"PATH","pdp":"P''","pld":"Prelude","plts":"Platts","scala":"Scala","slash":"///","snusp":"SNUSP","th":"Thue","unl":"Unlambda","vol":"Volatile","wd":"Wierd","wl":"WordLang","ws":"WhiteSpace","wsa":"WSAssembly"}
{"alpl":"ALPL","b":"BrainFuck","b93":"Befunge-93","b98":"Befunge-98","cpp":"C++","df":"Deadfish","emm":"Emmental","fl":"FlufflePuff","ft":"FracTran","ftp":"FracTran++","glo":"Glypho","glos":"GlyphoShorthand","grs":"Grass","lazy":"LazyK","lzb":"LazyBird","mt":"Metatape","names":["ftp","lazy","slash","th","df","wl","b93","ws","pld","plts","grs","path","mt","pdp","cpp","lzb","glo","nul","glos","b","emm","fl","vol","alpl","unl","scala","ft","b98","senpai","ook","wd","wsa","snusp"],"nul":"NULL","ook":"Ook","path":"PATH","pdp":"P''","pld":"Prelude","plts":"Platts","scala":"Scala","senpai":"Senpai","slash":"///","snusp":"SNUSP","th":"Thue","unl":"Unlambda","vol":"Volatile","wd":"Wierd","wl":"WordLang","ws":"WhiteSpace","wsa":"WSAssembly"}
6 changes: 3 additions & 3 deletions mycologyReport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ y claims all of the following:
That the day of the month is 17
That the month is 10
That the year is 2021
That the time is 00 : 36 : 02
That the time is 02 : 04 : 38
That the size of the stack stack is 1
That the stack sizes are [ 0 ] from top to bottom
That the command-line arguments were: [ null ]
Expand Down Expand Up @@ -148,8 +148,8 @@ GOOD: all of A-Z reflected
Testing fingerprint HRTI... loaded.
UNDEF: G gives clock granularity as 1000 microseconds
GOOD: T reflected when called before M
UNDEF: S pushed 633000
UNDEF: T after M pushed 1000 and a second T, after 675 ys, pushed 6699000
UNDEF: S pushed 813000
UNDEF: T after M pushed 0 and a second T, after 675 ys, pushed 8078000
GOOD: ET reflected

Testing fingerprint MODE... not loaded.
Expand Down
305 changes: 305 additions & 0 deletions src/main/scala/senpai/Senpai.scala

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/main/scala/ui/EsoDefaults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import pdoubleprime.PDP
import platts.Platts
import prelude.{BFToPrelude, Prelude}
import scala_run.ScalaRun
import senpai.Senpai
import slashes.Slashes
import snusp.{BFToSNUSP, SNUSP}
import thue.Thue
Expand Down Expand Up @@ -70,7 +71,8 @@ object EsoDefaults extends EsoObj{
("wl", "WordLang"),
("lazy", "LazyK"),
("alpl", "ALPL"),
("lzb", "LazyBird"))
("lzb", "LazyBird"),
("senpai", "Senpai"))
val fileExtensionMap: immutable.HashMap[String, String] = mkMap(fileExtensionsVec)

val defInterpVec: Vector[Interpreter] = Vector[Interpreter](
Expand Down Expand Up @@ -100,7 +102,8 @@ object EsoDefaults extends EsoObj{
WordLang,
LazyK,
ALPL,
LazyBird)
LazyBird,
Senpai)
val defTransVec: Vector[Translator] = Vector[Translator](FlufflePuff, Ook, WSAssembly, GlyphoShorthand, LazyKAnyToUnl, LazyKAnyToIota, LazyKAnyToCC, LazyKAnyToJot)
val defGenVec: Vector[Transpiler] = Vector[Transpiler](BFToScala, BFToCPP, WhiteSpaceToScala, BFToSNUSP, BFToMetatape, BFToPrelude, BFToLazyK, LambdaToLazyKUnl, LambdaToUnlambda, DFToBF)

Expand Down
14 changes: 14 additions & 0 deletions src/test/scala/senpai/SenpaiSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package senpai

import common_test.EsoSpec

class SenpaiSpec extends EsoSpec{
testAllAgainstOutputAutoLimit(Senpai)(
("hworld.senpai", "", "Hello World!\n", false),
("cat.senpai", (('a' to 'z') ++ ('A' to 'Z') ++ ('0' to '9') ++ "\n").mkString, (('a' to 'z') ++ ('A' to 'Z') ++ ('0' to '9') ++ "\n").mkString, false),
("truthmachine0.senpai", "0\n", "0\n", false),
("truthmachine1.senpai", "1\n", "1\n1\n1\n1\n1", true), //Whelp, time to properly redo my testing tools! Oh god...
("fizzbuzz.senpai", "", "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz\n", false),
("quine.senpai", "", grabFile("quine.senpai") + "\n", false),
("beer.senpai", "", grabFile("senpai_beer_result.txt"), false))
}
121 changes: 4 additions & 117 deletions src/test/scala/ui/CommandHandlerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -499,59 +499,7 @@ class SetDefaultsHandlerSpec extends CommandHandlerSpec{
class ListLangsHandlerSpec extends CommandHandlerSpec{
def currentHandler(eio: EsoTestInterface, efi: EsoFileInterface): CommandHandler = ListLangsHandler(eio)

val ref: String =
"""Languages...
|- ///
|- ALPL
|- Befunge-93
|- Befunge-98
|- BrainFuck
|- Deadfish
|- Emmental
|- FracTran
|- FracTran++
|- Glypho
|- Grass
|- LazyBird
|- LazyK
|- Metatape
|- NULL
|- P''
|- PATH
|- Platts
|- Prelude
|- SNUSP
|- Scala
|- Thue
|- Unlambda
|- Volatile
|- WhiteSpace
|- Wierd
|- WordLang
|
|Translators...
|- FlufflePuff <=> BrainFuck
|- GlyphoShorthand <=> Glypho
|- LazyK_CC <=> LazyK
|- LazyK_Iota <=> LazyK
|- LazyK_Jot <=> LazyK
|- LazyK_Unlambda <=> LazyK
|- Ook <=> BrainFuck
|- WSAssembly <=> WhiteSpace
|
|Transpilers...
|- BrainFuck => C++
|- BrainFuck => LazyK
|- BrainFuck => Metatape
|- BrainFuck => Prelude
|- BrainFuck => SNUSP
|- BrainFuck => Scala
|- Deadfish => BrainFuck
|- Lambda_Calculus => LazyK_Unlambda
|- Lambda_Calculus => Unlambda
|- WhiteSpace => Scala
|
|""".stripMargin
val ref: String = grabFile("list_langs_reference.txt")

"ListLangsHandler" should "correctly list the default language components" in {
val (_, res) = runWithArgs()()()
Expand All @@ -561,33 +509,7 @@ class ListLangsHandlerSpec extends CommandHandlerSpec{
class listVarsHandlerSpec extends CommandHandlerSpec{
def currentHandler(eio: EsoTestInterface, efi: EsoFileInterface): CommandHandler = ListVarsHandler(eio)

val ref: String =
"""Runtime Parameters...
|- appendInp = false (append console input to the end of file input (useful for some self-interpreters))
|- bfDiv = true (toggle whether or not divison by 0 evaluates to 0 in Befunge-98)
|- bfRetCode = false (toggle whether or not the Befunge-98 return code is displayed)
|- cache = true (cache initialized state of programs for faster repeated loading)
|- debug = false (toggle debug information for the interface and languages that support it)
|- dfChar = true (toggle whether or not to print Deadfish output as char values)
|- dyn = false (resize tape as needed for BF interpreter to eliminate memory limitations)
|- echoFileInp = false (print file input to the console as it is used, makes it look as if the input was entered into the console directly)
|- fPtr = true (toggle whether output for P'' programs starts at the read head going right or at the end of the tape going left)
|- indent = false (toggle whether or not to neatly indent generated Scala code)
|- log = false (toggle detailed console logging)
|- normLineBreaks = true (normalize all line breaks to '\n' when reading source files (for instance, '\r\n' => '\n'))
|- pNull = false (toggle whether to print the null/empty character in the output of P'' programs)
|- preludePar = false (run Prelude voices in parallel, can speed up execution of some programs)
|- printNum = false (print output as numerical values rather than characters)
|- sHead = true (toggle whether the read head starts at the beginning of the initial tape or the right end of the tape for P'')
|- time = false (print program duration on completion)
|- bfOpt = 2 (BrainFuck interpreter selection: 0=base, 1=optimized, 2=compiled)
|- charWidth = 8 (bit width of input characters for languages that do bitwise I/O)
|- fileEOF = 0 (character value to end file input strings with)
|- init = 40000 (initial tape size for interpreters with a data tape)
|- methSize = 1000 (maximum number of blocks in a generated method (for compiling interpreters)
|- olen = -1 (maximum output length, useful for non-terminating programs, -1=infinite)
|
|""".stripMargin
val ref: String = grabFile("help_reference.txt")

"listVarsHandler" should "correctly list the default runtime parameters" in {
val (_, res) = runWithArgs()()()
Expand All @@ -597,42 +519,7 @@ class listVarsHandlerSpec extends CommandHandlerSpec{
class listFileAssociationsHandlerSpec extends CommandHandlerSpec{
def currentHandler(eio: EsoTestInterface, efi: EsoFileInterface): CommandHandler = ListFileAssociationsHandler(eio)

val ref: String =
"""|File Associations...
|- .alpl => ALPL
|- .b => BrainFuck
|- .b93 => Befunge-93
|- .b98 => Befunge-98
|- .cpp => C++
|- .df => Deadfish
|- .emm => Emmental
|- .fl => FlufflePuff
|- .ft => FracTran
|- .ftp => FracTran++
|- .glo => Glypho
|- .glos => GlyphoShorthand
|- .grs => Grass
|- .lazy => LazyK
|- .lzb => LazyBird
|- .mt => Metatape
|- .nul => NULL
|- .ook => Ook
|- .path => PATH
|- .pdp => P''
|- .pld => Prelude
|- .plts => Platts
|- .scala => Scala
|- .slash => ///
|- .snusp => SNUSP
|- .th => Thue
|- .unl => Unlambda
|- .vol => Volatile
|- .wd => Wierd
|- .wl => WordLang
|- .ws => WhiteSpace
|- .wsa => WSAssembly
|
|""".stripMargin
val ref: String = grabFile("file_association_reference.txt")

"ListFileAssociationsHandler" should "correctly list the default file associations" in {
val (_, res) = runWithArgs()()()
Expand All @@ -654,7 +541,7 @@ class listFileAssociationsHandlerSpec extends CommandHandlerSpec{
class SaveFileAssociationsHandlerSpec extends CommandHandlerSpec{
def currentHandler(eio: EsoTestInterface, efi: EsoFileInterface): CommandHandler = SaveFileAssociationsHandler(efi)

val refStr: String = """{"alpl":"ALPL","b":"BrainFuck","b93":"Befunge-93","b98":"Befunge-98","cpp":"C++","df":"Deadfish","emm":"Emmental","fl":"FlufflePuff","ft":"FracTran","ftp":"FracTran++","glo":"Glypho","glos":"GlyphoShorthand","grs":"Grass","lazy":"LazyK","lzb":"LazyBird","mt":"Metatape","names":["ftp","lazy","slash","th","df","b98","wl","b93","ws","pld","plts","grs","path","mt","pdp","cpp","lzb","glo","nul","glos","b","emm","fl","vol","alpl","unl","scala","ft","ook","wd","wsa","snusp"],"nul":"NULL","ook":"Ook","path":"PATH","pdp":"P''","pld":"Prelude","plts":"Platts","scala":"Scala","slash":"///","snusp":"SNUSP","th":"Thue","unl":"Unlambda","vol":"Volatile","wd":"Wierd","wl":"WordLang","ws":"WhiteSpace","wsa":"WSAssembly"}"""
val refStr: String = grabFile("file_association_reference.json")

"SaveFileAssociationsHandler" should "correctly save file associations to the default file with no arguments" in {
val efi = MutableContainedFileInterface.withElms()
Expand Down
32 changes: 32 additions & 0 deletions testResources/beer.senpai
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Senpai? Can I see your i?
Senpai? Can I see your text?
Your i is very 99!

Let's keep this going as long as you likey i is not equal to "No more":
Your text is very "bottles of beer."!
Show me your text!
Show me your i!
Your text is very "bottles of beer on the wall."!
Show me your text!
Show me your i!
Show me your love!
Notice me, senpai!!!!

Your i is very i minus 1!
If you no-likey i:
Your i is very "No more"!
Let's move on now!
Your text is very "bottles of beer on the wall"!
Show me your text!
Show me your i!

Your text is very "Take one down, pass it around."!
Show me your text!
Show me your love!
Notice me, senpai!!!
We can stop now!

Your text is very "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall."!
Show me your text!
Show me your love!
Notice me, senpai!
4 changes: 4 additions & 0 deletions testResources/cat.senpai
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Show me your reason!
Notice me, senpai
Show me your love!
Notice me, senpai!
1 change: 1 addition & 0 deletions testResources/file_association_reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"alpl":"ALPL","b":"BrainFuck","b93":"Befunge-93","b98":"Befunge-98","cpp":"C++","df":"Deadfish","emm":"Emmental","fl":"FlufflePuff","ft":"FracTran","ftp":"FracTran++","glo":"Glypho","glos":"GlyphoShorthand","grs":"Grass","lazy":"LazyK","lzb":"LazyBird","mt":"Metatape","names":["ftp","lazy","slash","th","df","wl","b93","ws","pld","plts","grs","path","mt","pdp","cpp","lzb","glo","nul","glos","b","emm","fl","vol","alpl","unl","scala","ft","b98","senpai","ook","wd","wsa","snusp"],"nul":"NULL","ook":"Ook","path":"PATH","pdp":"P''","pld":"Prelude","plts":"Platts","scala":"Scala","senpai":"Senpai","slash":"///","snusp":"SNUSP","th":"Thue","unl":"Unlambda","vol":"Volatile","wd":"Wierd","wl":"WordLang","ws":"WhiteSpace","wsa":"WSAssembly"}
35 changes: 35 additions & 0 deletions testResources/file_association_reference.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
File Associations...
- .alpl => ALPL
- .b => BrainFuck
- .b93 => Befunge-93
- .b98 => Befunge-98
- .cpp => C++
- .df => Deadfish
- .emm => Emmental
- .fl => FlufflePuff
- .ft => FracTran
- .ftp => FracTran++
- .glo => Glypho
- .glos => GlyphoShorthand
- .grs => Grass
- .lazy => LazyK
- .lzb => LazyBird
- .mt => Metatape
- .nul => NULL
- .ook => Ook
- .path => PATH
- .pdp => P''
- .pld => Prelude
- .plts => Platts
- .scala => Scala
- .senpai => Senpai
- .slash => ///
- .snusp => SNUSP
- .th => Thue
- .unl => Unlambda
- .vol => Volatile
- .wd => Wierd
- .wl => WordLang
- .ws => WhiteSpace
- .wsa => WSAssembly

28 changes: 28 additions & 0 deletions testResources/fizzbuzz.senpai
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Senpai? Can I see your range?
Your range is very 100!
Senpai? Can I see your d?
Your d is very 0!
Senpai? Can I see your b?
Let's keep this going as long as you no-likey d is equal to range:
Your d is very d and 1!
If you likey (d mod 5 is equal to 0) and also (d mod 15 is not equal to 0):
Your b is very "Buzz"!
Show me your b!
Otherwise:
If you likey (d mod 3 is equal to 0) and also (d mod 15 is not equal to 0):
Your b is very "Fizz"!
Show me your b!
Otherwise:
If you no-likey d mod 15:
Your b is very "FizzBuzz"!
Show me your b!
Otherwise:
If you likey (d mod 3) either or (d mod 5):
Show me your d!
Let's move on now!
Let's move on now!
Let's move on now!
Let's move on now!
Show me your love!
Notice me, senpai!
We can stop now!
Loading

0 comments on commit 1670229

Please sign in to comment.