Skip to content

Commit

Permalink
Merge pull request #1 from julianmendez/17-updated-documentation
Browse files Browse the repository at this point in the history
17 translation of packages to single files
  • Loading branch information
julianmendez authored Mar 1, 2023
2 parents 28e9cd6 + fa67fd0 commit 52047cc
Show file tree
Hide file tree
Showing 492 changed files with 12,432 additions and 11,631 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# CI configuration
# https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven
# https://github.com/actions/setup-java

name: Scala CI

on:
- push

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java:
- 11
- 17
scala:
- 2.11.12
- 2.12.17
- 2.13.10
- 3.2.2
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: zulu
- name: Build with sbt
run: sbt '++ ${{ matrix.scala }}' scalaVersion sbtVersion version clean compile test package assembly


24 changes: 0 additions & 24 deletions bitbucket-pipelines.yml

This file was deleted.

16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import sbt.Keys.scalacOptions

lazy val scala2_11 = "2.11.12"

lazy val scala2_12 = "2.12.16"
lazy val scala2_12 = "2.12.17"

lazy val scala2_13 = "2.13.8"
lazy val scala2_13 = "2.13.10"

lazy val scala3_1 = "3.1.3"
lazy val scala3_2 = "3.2.2"

lazy val commonSettings =
Seq(
organization := "se.umu.cs.rai.soda",
version := "0.16.0",
version := "0.17.0",
description := "Functional language to describe ethical problems",
homepage := Some(url("https://bitbucket.org/mendezjulian/soda")),
startYear := Some(2020),
licenses := Seq("Apache License Version 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
organizationName := "Responsible Artificial Intelligence - Umea University",
organizationHomepage := Some(url("https://www.umu.se/en/research/groups/responsible-artificial-intelligence")),
developers := List(
Developer("julianmendez", "Julian Mendez", "[email protected]", new URL("https://julianmendez.github.io"))
Developer("julianmendez", "Julian Alfredo Mendez", "[email protected]", new URL("https://julianmendez.github.io"))
),
/**
* Scala
Expand All @@ -28,15 +28,15 @@ lazy val commonSettings =
* [[https://repo1.maven.org/maven2/org/scala-lang/scalap/]]
* [[https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/]]
*/
crossScalaVersions := Seq(scala2_11, scala2_12, scala2_13, scala3_1),
scalaVersion := scala3_1,
crossScalaVersions := Seq(scala2_11, scala2_12, scala2_13, scala3_2),
scalaVersion := scala3_2,
/**
* ScalaTest
* [[https://www.scalatest.org]]
* [[https://github.com/scalatest/scalatest]]
* [[https://repo1.maven.org/maven2/org/scalatest/]]
*/
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.13" % "test",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % "test",
resolvers += Resolver.mavenLocal,
publishTo := Some(Resolver.mavenLocal),
publishMavenStyle := true,
Expand Down
52 changes: 17 additions & 35 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,24 @@ The reserved words are:
- `->` (type mapping symbol)
- `=` (definition symbol)
- `:=` (parameter definition symbol)
- `lambda`
- `-->` (lambda symbol)
- `if`
- `then`
- `else`
- `match`
- `case`
- `==>` (implication symbol in pattern matching)
- `class`
- `extends`
- `abstract`
- `end`
- `this`
- `subtype`
- `supertype`
- `false`
- `true`
- `not`
- `and`
- `or`
- `package`
- `import`
- `theorem`
- `proof`
- `lambda`, `any` (synonym of `lambda`), `-->` (lambda symbol)
- `if`, `then`, `else`
- `match`, `case`, `==>` (implication symbol in pattern matching)
- `class`, `extends`, `abstract`, `end`
- `this`, `subtype`, `supertype`
- `false`, `true` , `not`, `and`, `or`
- `package`, `import`
- `theorem`, `proof`


## Other Symbols

In addition, the language has:

- `(` and `)` (parentheses) for parameters and operator precedence
- `[` and `]` (square brackets) for types
- `[` and `]` (square brackets) for parametric types

The main arithmetic operators are:

- `+`
- `-`
- `*`
- `/`
- `%`
- `+`, `-`, `*`, `/`, `%` (modulus)

Comments are marked with `/*` and `*/`. Scaladoc / Javadoc markers are `/**` and `*/`.

Expand All @@ -75,8 +53,7 @@ Special names:

In this language, variables cannot change their value. Therefore, there is no equivalent to `var`.

For example, it is not possible to write `x = x + 1`. Loops can be managed with `range` and `fold` functions, tail
recursion, or directly using streams.
For example, it is not possible to write `x = x + 1`. Loops can be managed with `range` and `fold` functions, tail recursion, or directly using streams.

The language does not provide `throw`, `try`, and `catch`, because those commands do not follow the functional style.

Expand Down Expand Up @@ -105,11 +82,16 @@ The following tools can be configured to have syntax highlighting:

## Build

The project can be build with [sbt](https://www.scala-sbt.org/).
The project can be built with [sbt](https://www.scala-sbt.org/).

The command is:
`sbt clean compile test package assembly`

It is also possible to compile it for different Scala versions.


## Author

[Julian Alfredo Mendez](https://julianmendez.github.io)


18 changes: 16 additions & 2 deletions docs/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
---
- - version: v0.16.0
- - version: v0.17.0
- date: '2023-03-01'
- build: sbt '++ 3.2.2' clean compile test package assembly
- release: target/scala-3.2.2/soda-0.17.0.jar
- new_features:
- includes an option to translate a whole Soda package into a single Scala file
- reads `Package.soda` as prelude for a Soda file in the same directory
- requires `match`-`case` structures to be used at most once in a function definition, and cannot be nested in another structure
- improves function definition by allowing multiple lines in its signature
- accepts reserved word `any` as a synonym for `lambda`
- accepts Unicode characters for reserved words, like the letter lambda for `lambda` and right arrows for `->`, `-->`, and `==>`
- includes a Bash script (`makeall.sh`) to build the project and create the binary file
- deprecated_features:
- the `end` reserved word for `match`-`case` is no longer used
- version: v0.16.0
- date: '2022-08-02'
- new_features:
- includes an extension to generate LaTeX files from source code
Expand Down Expand Up @@ -132,7 +146,7 @@
- includes a file expansion of a basic library when it finds `lib.soda`
- produces better looking Scala translated source code
- deprecated_features:
- does not longer support the use of tuples on the left-hand side of a definition sign (`=`)
- does not support any longer the use of tuples on the left-hand side of a definition sign (`=`)
- bug_fixes:
- fixes translation of constants that are lambda functions
- build: sbt '++ 3.0.0-RC2' clean compile test package assembly
Expand Down
22 changes: 17 additions & 5 deletions documentation/src/site/tex/common/language.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\usepackage{listings}

\lstdefinelanguage{Soda}{
morekeywords={lambda, if, then, else, match, case, class, extends, abstract, end, this, subtype, supertype, false, true, not, and, or, package, import, theorem, proof, @new, @tailrec, @override},
morekeywords={lambda, any, if, then, else, match, case, class, extends, abstract, end, this, subtype, supertype, false, true, not, and, or, package, import, theorem, proof, @new, @tailrec, @override},
sensitive=true,
morecomment=[s]{/*}{*/},
morestring=[b]"
Expand Down Expand Up @@ -43,19 +43,20 @@
\newcommand{\sodadef}{\srccode{=}\xspace}
\newcommand{\sodacolon}{\srccode{:}\xspace}
\newcommand{\sodaarrow}{{-\textgreater}\xspace}
\newcommand{\sodalambdaarrow}{{---\textgreater}\xspace}
\newcommand{\sodaimplies}{{==\textgreater}\xspace}
\newcommand{\sodadefparam}{\srccode{:=}\xspace}
\newcommand{\sodalambdaarrow}{\ensuremath{\longrightarrow}\xspace}
\newcommand{\sodacasearrow}{\ensuremath{\Longrightarrow}\xspace}

\newcommand{\sodalambda}{\reservedWordSoda{lambda}}
\newcommand{\sodaany}{\reservedWordSoda{any}}

\newcommand{\sodaif}{\reservedWordSoda{if}}
\newcommand{\sodathen}{\reservedWordSoda{then}}
\newcommand{\sodaelse}{\reservedWordSoda{else}}

\newcommand{\sodamatch}{\reservedWordSoda{match}}
\newcommand{\sodacase}{\reservedWordSoda{case}}
\newcommand{\sodaendmatch}{\reservedWordSoda{end}}

\newcommand{\sodaclass}{\reservedWordSoda{class}}
\newcommand{\sodaextends}{\reservedWordSoda{extends}}
Expand All @@ -74,6 +75,9 @@
\newcommand{\sodapackage}{\reservedWordSoda{package}}
\newcommand{\sodaimport}{\reservedWordSoda{import}}

\newcommand{\sodatheorem}{\reservedWordSoda{theorem}}
\newcommand{\sodaproof}{\reservedWordSoda{proof}}

\newcommand{\sodanew}{\annotation{@new}}
\newcommand{\sodatailrec}{\annotation{@tailrec}}
\newcommand{\sodaoverride}{\annotation{@override}}
Expand Down Expand Up @@ -120,11 +124,19 @@

\newcommand{\coqmatch}{\reservedWordCoq{match}}
\newcommand{\coqwith}{\reservedWordCoq{with}}
\newcommand{\coqbar}{\reservedWordCoq{|}}
\newcommand{\coqend}{\reservedWordCoq{end}}
\newcommand{\coqcasebar}{\reservedWordCoq{|}}
\newcommand{\coqcasearrow}{\ensuremath{\Rightarrow}\xspace}
\newcommand{\coqendmatch}{\reservedWordCoq{end}}

\newcommand{\coqDefinition}{\reservedWordCoq{Definition}}
\newcommand{\coqNotation}{\reservedWordCoq{Notation}}
\newcommand{\coqInductive}{\reservedWordCoq{Inductive}}
\newcommand{\coqFixpoint}{\reservedWordCoq{Fixpoint}}
\newcommand{\coqRequire}{\reservedWordCoq{Require}}
\newcommand{\coqImport}{\reservedWordCoq{Import}}
\newcommand{\coqModule}{\reservedWordCoq{Module}}
\newcommand{\coqEnd}{\reservedWordCoq{End}}
\newcommand{\coqTheorem}{\reservedWordCoq{Theorem}}
\newcommand{\coqProof}{\reservedWordCoq{Proof}}
\newcommand{\coqQed}{\reservedWordCoq{Qed}}

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ \chapter{Reserved Words}
\hline
\sodaif $b$ \sodathen $e_{0}$ \sodaelse $e_{1}$ & expression if $b$ is true, then $e_{0}$, else $e_{1}$ \\
\hline
\sodamatch $x$ \sodacase $p_{i}$ \sodaimplies $e_{i}$ \sodaendmatch & pattern matching from $p_{i}$ to $e_{i}$ for $1 \leq i \leq n$ \\
\sodamatch $x$ \sodacase $p_{i}$ \sodaimplies $e_{i}$ & pattern matching from $p_{i}$ to $e_{i}$ for $1 \leq i \leq n$ \\
\hline
\sodaclass $B$ \sodaextends $A_{1} \ldots A_{n}$ & class $B$ extends classes $A_{0}$ and $A_{1}$ \\
\sodaclass $B$ [$A_{0}$ \sodasubtype $A_{1}$ ] & class $B$ requires a class $A_{0}$ which extends $A_{1}$ \\
Expand Down
29 changes: 0 additions & 29 deletions examples/src/main/scala/soda/example/algorithms/FizzBuzz.scala

This file was deleted.

23 changes: 10 additions & 13 deletions examples/src/main/scala/soda/example/algorithms/FizzBuzz.soda
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package soda.example.algorithms

class FizzBuzz

import
soda.lib.Recursion_

fizz = "Fizz"

buzz = "Buzz"

fizz_buzz =
Recursion_ ()
.range (100)
_range = soda.lib.Range_ ()

apply : Seq [String] =
_range.apply (100)
.map ( lambda (x : Int) --> x + 1)
.map (get_fizz_buzz_term)
.map (_get_fizz_buzz_term)

get_fizz_buzz_term (n : Int) =
if is_divisible_by (n) (15) then fizz + buzz
else if is_divisible_by (n) (3) then fizz
else if is_divisible_by (n) (5) then buzz
_get_fizz_buzz_term (n : Int) : String =
if _is_divisible_by (n) (15) then fizz + buzz
else if _is_divisible_by (n) (3) then fizz
else if _is_divisible_by (n) (5) then buzz
else n.toString

is_divisible_by (n : Int) (k : Int) : Boolean =
_is_divisible_by (n : Int) (k : Int) : Boolean =
n % k == 0

end

This file was deleted.

Loading

0 comments on commit 52047cc

Please sign in to comment.