https://github.com/dplassgit/ssl-compilers
Compilers for "SSL", a "simple scripting language"
https://github.com/dplassgit/ssl-compilers
compiler compiler-construction toy-language
Last synced: 12 months ago
JSON representation
Compilers for "SSL", a "simple scripting language"
- Host: GitHub
- URL: https://github.com/dplassgit/ssl-compilers
- Owner: dplassgit
- License: mit
- Created: 2024-02-15T00:23:51.000Z (about 2 years ago)
- Default Branch: trunk
- Last Pushed: 2024-04-09T01:33:45.000Z (almost 2 years ago)
- Last Synced: 2024-04-09T02:38:41.404Z (almost 2 years ago)
- Topics: compiler, compiler-construction, toy-language
- Language: Rust
- Homepage:
- Size: 3.92 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SSL Compilers
Compilers for "SSL", a "simple scripting language."
Just for fun, I want to write the same compiler in different source languages.
The compilers all emit x64 assembly language.
## Language
See [language overview](docs/LANGUAGE.md).
## Development history
I built the Python version first. It's also the smallest, at only about 500 lines.
Then I built the Java version, including some JUnit tests. I have the most
experience with Java (including the d2lang compiler).
C++ was a challenge, because I hadn't written any in a long time (like, 25 years).
I don't remember C++ being so annoying with declaring every method in the header
file.
Next I built the golang version. This is now the most golang I have ever written
(about 700 lines). Since golang doesn't really have classes, it was odd to have
to add `(this *Parser)` for every method. Also, golang doesn't have method
overloading, which I also found surprising.
The C version was really annoying because:
* It doesn't have "simple" string concatenation
* No built-in map, set, list
I had heard lots about Kotlin but never written a line of code before this
project. I think I enjoyed the Kotlin version the most so far, maybe because
of how it so easily builds string literals. The language reminds me of the best
parts of Java and the best parts of Python.
(At this point I started writing tests with the code, instead of having to run
against the samples manually.)
Ruby was ok. It thinks it's a better Python, but to me, I feel it's like
the worst of Python and JavaScript...
Scala was new for me as well. It seems to be a cross between Kotlin and Python.
I liked the ability to automatically run tests whenever a file changed (via the
`~test` command in `sbt`.)
I went back and added tests for Python, Go and C++, when I revamped the two-character
symbol lexical analysis.
The awk implementation was kind of fun, but annoying, because it's completely
un-type-checked. If you mistype a variable, it defaults to null/undefined, instead of
giving an error...
Rust was a challenge; I started and stopped it a few times before finally
getting the basics figured out. I still don't quite understand its memory or
module models, but know just enough to be dangerous.
Future languages may include:
* [d2lang](https://github.com/dplassgit/d2lang)
* D
* [Sly](https://github.com/dabeaz/sly) (a Python parser generator)
* [ANTLR](https://www.antlr.org/) ("Another Tool for another parser generator")