Skip to content

Instantly share code, notes, and snippets.

@haxscramper
Last active March 16, 2024 19:45
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save haxscramper/3562fa8fee4726d7a30a013a37977df6 to your computer and use it in GitHub Desktop.
Save haxscramper/3562fa8fee4726d7a30a013a37977df6 to your computer and use it in GitHub Desktop.
languages-and-vms

Language & VM design

Lexing & parsing

Articles

Writing own parser

  1. nimly - Lexer Generator and Parser Generator as a Library in Nim.

    With nimly, you can make lexer/parser by writing definition in formats like lex/yacc. nimly generates lexer and parser by using macro in compile-time, so you can use nimly not as external tool of your program but as a library.

  2. npeg - parsing expression grammars in nim

    NPeg is a pure Nim pattern matching library. It provides macros to compile patterns and grammars (PEGs) to Nim procedures which will parse a string and collect selected parts of the input.K

  3. lilt parser generator

    Lilt is a content-free parser generator. It accepts a specification and returns a parser based on that specification. Lilt specifications look very similar to Backus-Naur form, but have extra syntax in order to be a parser generator rather than just a grammar specification.

  4. std/lexbase - This module implements a base object of a lexer with efficient buffer handling.

  5. hparse - Collection of parser utilities for nim - compile/runtime parser generator.

    Collection of various utilities related to parsing, ranging from statically typed wrapper on top of scanf to full parser generator (with support for EBNF notation, tree actions, template rules, compile/runtime parsing and automatic parse tree generation)

  6. std/parseutils

  7. std/strscans

  8. std/pegs

  9. std/strutils

  10. honeycomb Honeycomb is a parser combinator library written in pure Nim. It's designed to be simple, straightforward, and easy to expand, while relying on zero dependencies from outside of Nim's standard library.

  11. lrparser An SLR library parser for Nim

Processing existing languages

  1. Tree-sitter wrappers

  2. std/parsesql - sql

  3. hcparse - Higher-level bindings for libclang in nim.

  4. protobuf-nim - Protobuf implementation in pure Nim that leverages the power of the macro system to not depend on any external tools

  5. yaml - NimYAML is a pure YAML implementation for Nim. It is able to read from and write to YAML character streams, and to serialize from and construct to native Nim types. It exclusively supports YAML 1.2.

  6. std/xmlparser, std/parsexml - xml # What is the difference?

  7. std/json - json

  8. std/parsecsv - csv

  9. std/sexp S-expressions parser

VM, JIT, Emulators

  1. photon jit - A JIT Assembler for Nim
  2. catnip - A library for runtime code generation (runtime assembler e.g. for JIT recompilers.)
  3. nimoric Oric emulator written in Nim
  4. nimes NimES: NES Emulator in Nim
  5. gbemulator GameBoy emulator written in Nim
  6. vcpu A virtual machine for code obfuscation
  7. nim-lang implements register-based VM for nimscript.

Examples

Examples of language implementation in nim.

  1. nim-lang itself - compiler is written entirely in nim
  2. japl - JAPL is an interpreted, dynamically-typed, garbage-collected and minimalistic programming language with C- and Java-like syntax.
  3. arturo - Simple, modern and portable interpreted programming language for efficient scripting
  4. spry - A Smalltalk and Rebol inspired language implemented as an AST interpreter in Nim
  5. make a lisp implementation in nim
  6. two implementations of lox language from https://craftinginterpreters.com/
  7. hayago - hayago is a small, fast, embeddable, statically typed scripting language, written in Nim. Its syntax is inspired by Nim itself.
  8. min is a functional, concatenative programming language with a minimalist syntax, a small but practical standard library, and an advanced REPL. All packed in about 1MB*.
  9. tsuki (jap. 月, moon) is a lightweight, dynamically typed, modular, embeddable scripting language for Nim, inspired by Lua, Ruby, and Nim itself.
  10. vitamin Vitamin is a general-purpose programming language with a rich type system, clear semantics, and great flexibility. Vitamin will give you ultimate power when you need it, and won't get in your way when you don't.
  11. wolf-lang A simple, lightweight modern Lisp-like language made in Nim
  12. candyscript A minimal single-line programming language for writing web servers and restAPIs
  13. nael An experimental language, based on the stack-oriented programming language by the name of Factor.
  14. ajl A simple whitespace-sensitive transpile to the C++ programming language
  15. vaja Väja is a dynamic interpreted language inspired by Elixir, Lua, Python, Nim and Monkey.
  16. fes Compile a Forth like programming language (+ some small additions) to 6502 Assembly (specifically for the NES (Nintendo Entertainment System).
  17. pipelines An experimental programming language for data flow
  18. Flori a low fat programming language for system/application with region.
  19. Nim0 Nim0 is a toy one-pass compiler for a limited subset of the Nim language, targetting a 32-bit RISC CPU. Compiled Nim0 programs can be executed in the RISC emulator. All this in 5 heavily-documented sources, totalling less than 4k LOC. It is a port of Niklaus Wirth's Oberon-0 compiler as described in his book Compiler construction (included in the package), cross-referenced in the sources, that you can follow while reading the book.
  20. Let's Build a Compiler, by Jack Crenshaw Nim version of the https://compilers.iecc.com/crenshaw/ -- fifteen-part series, written from 1988 to 1995, is a non-technical introduction to compiler construction.
  21. gene-new Gene - a general purpose language
  22. nondescript Nondescript is a nim implementation of lox (see craftinginterpreters.com) with large deviations.
  23. panther The panther language is a language made for exploitations. It's main focus is minimal code size through code size optimizations and compiling directly to a shellcode (position independent code).
  24. Peon Peon is a simple, functional, async-first programming language with a focus on correctness and speed
@qaziquza
Copy link

qaziquza commented Nov 17, 2021

Typo report:
Section "Examples", "implementatin" -> "implementation"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment