From 151f68a55dbfb6959d8edcc464581db48c49e48a Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Fri, 28 Aug 2020 02:18:25 -0400 Subject: [PATCH] add nescant --- README.md | 2 ++ build.sbt | 4 ++++ .../scala/com/htmlism/nescant/GlobalAddress.scala | 5 +++++ .../main/scala/com/htmlism/nescant/Operand.scala | 7 +++++++ .../src/main/scala/com/htmlism/nescant/Sink.scala | 7 +++++++ .../main/scala/com/htmlism/nescant/Source.scala | 8 ++++++++ .../com/htmlism/nescant/ZeroPageAddress.scala | 5 +++++ .../scala/com/htmlism/nescant/dsl/package.scala | 11 +++++++++++ .../com/htmlism/nescant/dsl/PostFixOpsSpec.scala | 15 +++++++++++++++ project/LintingPlugin.scala | 2 +- 10 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala create mode 100644 nescant/src/main/scala/com/htmlism/nescant/Operand.scala create mode 100644 nescant/src/main/scala/com/htmlism/nescant/Sink.scala create mode 100644 nescant/src/main/scala/com/htmlism/nescant/Source.scala create mode 100644 nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala create mode 100644 nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala create mode 100644 nescant/src/test/scala/com/htmlism/nescant/dsl/PostFixOpsSpec.scala diff --git a/README.md b/README.md index b675add..d03e332 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ * IndirectX: argument is an 8-bit address; find a value at this address incremented by the value X * IndirectY: argument is an 8-bit address; find a value at this address; increment the value by Y +## TODO - Nescant + ## TODO 1. operand support should be derived from enum support diff --git a/build.sbt b/build.sbt index cb786a1..b69d759 100644 --- a/build.sbt +++ b/build.sbt @@ -8,3 +8,7 @@ lazy val root = .withCats .withTesting .withOrganizeImports + .aggregate(nescant) + +lazy val nescant = + project.withCats.withTesting.withOrganizeImports diff --git a/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala b/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala new file mode 100644 index 0000000..d083ed1 --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/GlobalAddress.scala @@ -0,0 +1,5 @@ +package com.htmlism.nescant + +object GlobalAddress {} + +case class GlobalAddress(n: Int) diff --git a/nescant/src/main/scala/com/htmlism/nescant/Operand.scala b/nescant/src/main/scala/com/htmlism/nescant/Operand.scala new file mode 100644 index 0000000..9684c45 --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/Operand.scala @@ -0,0 +1,7 @@ +package com.htmlism.nescant + +sealed trait Operand + +case class LiteralOperand(value: String) extends Operand + +case class NamedOperand(name: String, value: String) extends Operand diff --git a/nescant/src/main/scala/com/htmlism/nescant/Sink.scala b/nescant/src/main/scala/com/htmlism/nescant/Sink.scala new file mode 100644 index 0000000..61af4a9 --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/Sink.scala @@ -0,0 +1,7 @@ +package com.htmlism.nescant + +trait Sink[A] + +object Sink { + // TODO int cannot be a source +} diff --git a/nescant/src/main/scala/com/htmlism/nescant/Source.scala b/nescant/src/main/scala/com/htmlism/nescant/Source.scala new file mode 100644 index 0000000..8592c88 --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/Source.scala @@ -0,0 +1,8 @@ +package com.htmlism.nescant + +trait Source[A] + +object Source { + // TODO int can be a source + // TODO a volitile device can be a source +} diff --git a/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala b/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala new file mode 100644 index 0000000..9a4bf0d --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/ZeroPageAddress.scala @@ -0,0 +1,5 @@ +package com.htmlism.nescant + +object ZeroPageAddress {} + +case class ZeroPageAddress(n: Int) diff --git a/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala b/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala new file mode 100644 index 0000000..3ae5fa5 --- /dev/null +++ b/nescant/src/main/scala/com/htmlism/nescant/dsl/package.scala @@ -0,0 +1,11 @@ +package com.htmlism.nescant + +package object dsl { + implicit class AddressOps(n: Int) { + def z: ZeroPageAddress = + ZeroPageAddress(n) + + def g: GlobalAddress = + GlobalAddress(n) + } +} diff --git a/nescant/src/test/scala/com/htmlism/nescant/dsl/PostFixOpsSpec.scala b/nescant/src/test/scala/com/htmlism/nescant/dsl/PostFixOpsSpec.scala new file mode 100644 index 0000000..6d6931b --- /dev/null +++ b/nescant/src/test/scala/com/htmlism/nescant/dsl/PostFixOpsSpec.scala @@ -0,0 +1,15 @@ +package com.htmlism.nescant +package dsl + +import org.scalatest.flatspec._ +import org.scalatest.matchers._ + +class PostFixOpsSpec extends AnyFlatSpec with should.Matchers { + "Numbers" should "support zero page ops" in { + 123.z shouldBe ZeroPageAddress(123) + } + + it should "support global address ops" in { + 123.g shouldBe GlobalAddress(123) + } +} diff --git a/project/LintingPlugin.scala b/project/LintingPlugin.scala index f0ace3b..54ffbec 100644 --- a/project/LintingPlugin.scala +++ b/project/LintingPlugin.scala @@ -5,7 +5,7 @@ object LintingPlugin extends AutoPlugin { override def trigger = allRequirements override lazy val globalSettings = - addCommandAlias("fmt", List("all", "scalafmtSbt", "compile:scalafmt", "test:scalafmt").mkString(" ")) ++ + addCommandAlias("fmt", "scalafmtAll") ++ addCommandAlias("fix", "scalafixAll") object autoImport {