Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
vogon101 committed May 1, 2021
1 parent 5e27a05 commit 4549dd2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/scala_compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
# Scaly
_Compiling a Scala Inspired Language to CPython Bytecode_

## Command Line Usage
The command line application (`scaly.application.Compiler`) can be compiled to a jar file with `sbt assembly`.

```
scaly 0.1
Usage: scaly [run] [options] <input file>
<input file> Location of source file (required)
-o, --out <file> Output file - default is in file name with .pyc extension
--help Prints the usage text
Command: run
Run the program after compilation, requires python
````
## Project Structure
* `com.freddieposer.scaly`
* `application`
* `AST`
* `backend`
* `pyc` - Code for reading and writing compiled python files
* `internal` - InternalSyntaxTree (IST) for representing code pre-compilation
* `typechecker` - The TypeChecker generates an IST for use by the backend compiler
* `context`
* `types`
* `stdtypes` - Types in the standard library
* `backend`
* `pyc` - Code for reading and writing compiled python files
* `internal` - InternalSyntaxTree (IST) for representing code pre-compilation
* `utils` - Utility classes
* `tests` - Simple test suite
Expand All @@ -20,4 +35,3 @@ _Compiling a Scala Inspired Language to CPython Bytecode_
## Notes
* Targeting CPython 3.8 (latest version supported by anaconda3)
* Parsing is now done by [Scalameta](https://scalameta.org/) instead of ANTLR4
11 changes: 5 additions & 6 deletions src/main/scala/com/freddieposer/scaly/application/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ object Compiler {
programName("scaly"),
head("scaly", "0.1"),

opt[File]('i', "in")
.required()
.valueName("<file>")
arg[File]("<input file>")
.action((x, c) => c.copy(inputFile = Some(x)))
.text("in is a required file property"),
.text("Location of source file (required)"),

opt[File]('o', "out")
.valueName("<file>")
.action((x, c) => c.copy(inputFile = Some(x))),
.action((x, c) => c.copy(outputFile = Some(x)))
.text("Output file - default is in file name with .pyc extension"),

help("help")
.text("Prints the usage text"),

cmd("run")
.action((_, c) => c.copy(mode = COMPILE_AND_RUN))
.text("Run the compiled program")
.text("Run the program after compilation, requires python")

)
}
Expand Down
7 changes: 4 additions & 3 deletions test_suite/compiler/pattern_matching/S_pattern_matching.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Y: this
Z: This: this
One abc
123
Pattern One, Two 3
Pattern One, Wild 3
None
*/

Expand Down Expand Up @@ -46,8 +46,9 @@ object Main {

val q = t match {
case (0, x) => "Pattern zero " + str(x)
case (1, (20, x)) => "Pattern One, Twenty " + str(x)
case (1, (2, x)) => "Pattern One, Two " + str(x)
case (_, (20, x)) => "Pattern One, Twenty " + str(x)
case (1, (3, x)) => "Pattern One, Three " + str(x)
case (1, (_, x)) => "Pattern One, Wild " + str(x)
}

print(p)
Expand Down

0 comments on commit 4549dd2

Please sign in to comment.