mirror of
https://github.com/iritmaximus/compilers.git
synced 2026-10-12 19:13:35 +03:00
Started work on parser, submit works correctly
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-21.0.8_9_1.12.1_3.8.1 AS builder
|
||||
|
||||
WORKDIR /usr/src
|
||||
COPY . .
|
||||
|
||||
WORKDIR /usr/src/compiler
|
||||
|
||||
RUN sbt clean assembly
|
||||
|
||||
FROM eclipse-temurin:21
|
||||
|
||||
WORKDIR /usr/src
|
||||
COPY --from=builder /usr/src/compiler/target/scala-3.8.1/compiler-assembly-0.1.0-SNAPSHOT.jar compiler.jar
|
||||
COPY ./compiler ./
|
||||
|
||||
CMD ["java", "-jar", "compiler.jar"]
|
||||
@@ -0,0 +1 @@
|
||||
target
|
||||
@@ -6,6 +6,8 @@ lazy val root = project
|
||||
name := "compiler",
|
||||
version := "0.1.0-SNAPSHOT",
|
||||
|
||||
mainClass := Some("compiler.main"),
|
||||
|
||||
scalaVersion := scala3Version,
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scalameta" %% "munit" % "1.0.0" % Test,
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
// In project/plugins.sbt. Note, does not support sbt 0.13, only sbt 1.x.
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")
|
||||
|
||||
// Source - https://stackoverflow.com/a/30576584
|
||||
// Posted by shutty, modified by community. See post 'Timeline' for change history
|
||||
// Retrieved 2026-02-06, License - CC BY-SA 3.0
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
|
||||
|
||||
@@ -10,7 +10,7 @@ import compiler.Tokenizer._
|
||||
import compiler.Parser._
|
||||
|
||||
|
||||
@main def hello(): Unit =
|
||||
@main def main(): Unit =
|
||||
println("Hello world!")
|
||||
println(msg)
|
||||
run_server()
|
||||
@@ -44,8 +44,11 @@ def run_server(): Unit =
|
||||
case _ => s"{\"error\": \"Incorrect json request body\"}"
|
||||
}
|
||||
|
||||
|
||||
println(s"Responding with: ${response}")
|
||||
// Send response to the client
|
||||
out.println(response);
|
||||
out.println(response)
|
||||
out.close()
|
||||
|
||||
def compile(source: String): String =
|
||||
val tokens = Tokenizer.tokenize(source)
|
||||
|
||||
@@ -4,15 +4,15 @@ import scala.util.{Try, Success, Failure}
|
||||
|
||||
import compiler.Tokenizer.{Token, TokenType}
|
||||
|
||||
sealed trait Expression:
|
||||
sealed abstract class Expression:
|
||||
//override def toString() = s"${this.getClass.getName.stripPrefix("compiler.Parser.")}($this)"
|
||||
override def toString() = s"Expression(TODO)"
|
||||
|
||||
|
||||
class Literal(value: Int | Boolean) extends Expression
|
||||
class Identifier(name: String) extends Expression
|
||||
class BinaryOperator(left: Expression, operator: String, right: Expression) extends Expression
|
||||
class Other() extends Expression
|
||||
case class Literal(value: Int | Boolean) extends Expression
|
||||
case class Identifier(name: String) extends Expression
|
||||
case class BinaryOperator(left: Expression, operator: String, right: Expression) extends Expression
|
||||
case class Other() extends Expression
|
||||
|
||||
class Parser(tokens: List[Token]):
|
||||
// Keeps track of current token, index to tokens: List[Token]
|
||||
|
||||
Reference in New Issue
Block a user