Skip to content

Commit

Permalink
Update to Scala 3.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlucena committed Mar 9, 2024
1 parent 668966e commit 6f9b47c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "3.7.15"
runner.dialect = scala3
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use o IntelliSense para saber mais sobre os atributos possíveis.
// Focalizar para exibir as descrições dos atributos existentes.
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ThisBuild / scalaVersion := "3.3.1"
ThisBuild / scalaVersion := "3.3.3"
ThisBuild / organization := "com.github.lrlucena"
ThisBuild / version := "1.3.1"
ThisBuild / version := "1.3.3"

enablePlugins(Antlr4Plugin)

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.6
sbt.version=1.9.9
2 changes: 1 addition & 1 deletion project/metals.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.6")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.15")

39 changes: 20 additions & 19 deletions src/main/scala/whilelang/compiler/Semantics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ extension (src: Any)(using ids: Ids)
def meaning: String = m
private def m: String = src match
case If(cond, tSmt, eSmt) => s"if ${cond.m} then\n ${tSmt.m}\nelse\n ${eSmt.m}"
case Write(exp) => s"println(${exp.m})"
case Print(text) => s"println(\"$text\")"
case While(cond, doSmt) => s"while ${cond.m} do\n ${doSmt.m}"
case SeqStatement(stmts) => stmts.map(_.m).mkString("\n").replaceAll("\n", "\n ")
case Attrib(id, exp) => ids.add(id); s"$id = ${exp.m}"
case Program(seq) => val main = seq.m; s"@main def main() =\n ${vars(ids)}\n $main"
case Skip => "()"
case Read => "readInt()"
case Id(id) => id
case Integer(value) => s"$value"
case ExpSum(lhs, rhs) => s"(${lhs.m} + ${rhs.m})"
case ExpSub(lhs, rhs) => s"(${lhs.m} - ${rhs.m})"
case ExpMult(lhs, rhs) => s"(${lhs.m} * ${rhs.m})"
case Boole(b) => s"$b"
case ExpEq(lhs, rhs) => s"(${lhs.m} == ${rhs.m})"
case ExpLe(lhs, rhs) => s"(${lhs.m} <= ${rhs.m})"
case Not(b) => s"!(${b.m})"
case And(lhs, rhs) => s"(${lhs.m} && ${rhs.m})"
case _ => "~~~ Not Implemented ~~~"
case Write(exp) => s"println(${exp.m})"
case Print(text) => s"println(\"$text\")"
case While(cond, doSmt) => s"while ${cond.m} do\n ${doSmt.m}"
case SeqStatement(stmts) => stmts.map(_.m).mkString("\n").replaceAll("\n", "\n ")
case Attrib(id, exp) => ids.add(id); s"$id = ${exp.m}"
case Program(seq) => val main = seq.m
s"@main def main() =\n ${vars(ids)}\n $main"
case Skip => "()"
case Read => "readInt()"
case Id(id) => id
case Integer(value) => s"$value"
case ExpSum(lhs, rhs) => s"(${lhs.m} + ${rhs.m})"
case ExpSub(lhs, rhs) => s"(${lhs.m} - ${rhs.m})"
case ExpMult(lhs, rhs) => s"(${lhs.m} * ${rhs.m})"
case Boole(b) => s"$b"
case ExpEq(lhs, rhs) => s"(${lhs.m} == ${rhs.m})"
case ExpLe(lhs, rhs) => s"(${lhs.m} <= ${rhs.m})"
case Not(b) => s"!(${b.m})"
case And(lhs, rhs) => s"(${lhs.m} && ${rhs.m})"
case _ => "~~~ Not Implemented ~~~"
2 changes: 1 addition & 1 deletion src/main/scala/whilelang/parser/MyListener.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ class MyListener extends BaseListener with ContextValue:
val Seq(lhs, rhs) = ctx.expression.map(_.value[Expression])
ctx(1).text match
case "=" => ExpEq(lhs, rhs)
case _ => ExpLe(lhs, rhs)
case _ => ExpLe(lhs, rhs)
2 changes: 1 addition & 1 deletion while
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

java -Xmx1879m -jar ./target/scala-3.2.0/WhileLang-assembly-1.2.jar $1
java -Xmx1879m -jar ./target/scala-3.3.3/WhileLang-assembly-1.3.3.jar $1

0 comments on commit 6f9b47c

Please sign in to comment.