All Projects → true-grue → PigletC

true-grue / PigletC

Licence: MIT License
A toy C-like language compiler for PigletVM

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PigletC

tiny-lang
tiny-lang — A different programming language. Supports a bunch of spoken languages.
Stars: ✭ 26 (-49.02%)
Mutual labels:  compiler-design, compiler-frontend, compiler-construction
hascal
Hascal is a general purpose and open source programming language designed to build optimal, maintainable, reliable and efficient software.
Stars: ✭ 56 (+9.8%)
Mutual labels:  compiler-design, compiler-frontend
CaptCC
A tiny C compiler written purely in JavaScript.
Stars: ✭ 175 (+243.14%)
Mutual labels:  compiler-design, compiler-construction
JuCC
JuCC - Jadavpur University Compiler Compiler
Stars: ✭ 34 (-33.33%)
Mutual labels:  compiler-design, compiler-construction
ex spirit
No description or website provided.
Stars: ✭ 26 (-49.02%)
Mutual labels:  parser-combinators
blacklight
a stack-based concatenative virtual machine for implementing highly concurrent languages
Stars: ✭ 42 (-17.65%)
Mutual labels:  stack-machine
Kyoto
Kyoto Lang - A programming language designed to build WebAssembly
Stars: ✭ 16 (-68.63%)
Mutual labels:  compiler-design
CIBYL
Lightweight curly-bracket language which compiles to Ruby and Crystal.
Stars: ✭ 45 (-11.76%)
Mutual labels:  c-like
cppcombinator
parser combinator and AST generator in c++17
Stars: ✭ 20 (-60.78%)
Mutual labels:  compiler-construction
learning-reverse-engineering
This repository contains sample programs written primarily in C and C++ for learning native code reverse engineering.
Stars: ✭ 83 (+62.75%)
Mutual labels:  educational-project
rich4clojure
Practice Clojure using Interactive Programming in your editor
Stars: ✭ 126 (+147.06%)
Mutual labels:  educational-project
AutomationShield
Arduino library and MATLAB/Simulink API for the AutomationShield Arduino expansion boards for control engineering education.
Stars: ✭ 22 (-56.86%)
Mutual labels:  educational-project
SQLToy
An in-memory SQL database written in Javascript to demonstrate how SQL works.
Stars: ✭ 104 (+103.92%)
Mutual labels:  educational-project
Parsey
Swift Parser Combinators
Stars: ✭ 56 (+9.8%)
Mutual labels:  parser-combinators
leftry
Leftry - A left-recursion enabled recursive-descent parser combinator library for Lua.
Stars: ✭ 32 (-37.25%)
Mutual labels:  parser-combinators
Xacor
Experimental Game Engine
Stars: ✭ 24 (-52.94%)
Mutual labels:  educational-project
loquat
Monadic parser combinators for JavaScript / TypeScript
Stars: ✭ 47 (-7.84%)
Mutual labels:  parser-combinators
Windows-DLL-Injector
Some DLL Injection techniques in C++ implemented for both x86 and x64 windows OS processes
Stars: ✭ 174 (+241.18%)
Mutual labels:  educational-project
librxvm
non-backtracking NFA-based regular expression library, for C and Python
Stars: ✭ 57 (+11.76%)
Mutual labels:  compiler-design
ppc
A parser combinator library for PHP
Stars: ✭ 34 (-33.33%)
Mutual labels:  parser-combinators

PigletC — a tiny C-like language compiler for PigletVM

PigletC is based on raddsl toolset and was made for teaching purposes.

Simple example.

int r;
int n;

void main() {
  n = 5;
  r = 1;
  while (n > 1) {
    r = r * n;
    n = n - 1;
  }
  print(r);
}

Result of compilation.

PUSHI 1
PUSHI 5
STORE
PUSHI 0
PUSHI 1
STORE
L0:
PUSHI 1
LOAD
PUSHI 1
GREATER
JUMP_IF_FALSE L1
PUSHI 0
PUSHI 0
LOAD
PUSHI 1
LOAD
MUL
STORE
PUSHI 1
PUSHI 1
LOAD
PUSHI 1
SUB
STORE
JUMP L0
L1:
PUSHI 0
LOAD
PRINT
DONE

Result of VM execution.

pigletvm-exec asm fact.c.pvm fact.c.b
pigletvm-exec run fact.c.b
120
Result value: 0
PROFILE: switch code finished took 0ms
120
Result value: 0
PROFILE: switch code (no range check) finished took 1ms
120
Result value: 0
PROFILE: threaded code finished took 0ms
120
Result value: 0
PROFILE: trace code finished took 1ms
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].