Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
afl renamed and simplified commands Jun 16, 2017
cgen get C output to compile with poprc driver Feb 23, 2018
css fix web terminal Jan 23, 2018
linenoise @ c894b9e update linenoise Jan 4, 2017
lldb add log tag to all graphs Oct 24, 2017
org fix type dropping and add missing switch_entry Jan 21, 2018
patches added a Coccinelle patch that was used May 3, 2017
scripts renamed and simplified commands Jun 16, 2017
startle add assert_warn Jun 14, 2018
test_output update copyright notices Jun 19, 2018
tex added typing rules Aug 26, 2017
.gdbinit added my .gdbinit Sep 14, 2013
.gitignore update .gitignore Jan 24, 2018
.gitmodules added linenoise for line editing, a few bug fixes, cleaned up measure… May 5, 2013
.lldbinit added commands to lldb Sep 4, 2016
.travis.yml add .travis.yml May 19, 2017
.ycm_extra_conf.py fixed some warnings and ycmd configuration Mar 23, 2015
LICENSE updated license info Oct 7, 2012
Makefile add tests.ppr to eval.js Feb 5, 2018
README.md add web version link to README.md Jul 25, 2017
builders.h add auto-generated builders Jun 14, 2018
byte_compile.c update copyright notices Jun 19, 2018
cells.c update copyright notices Jun 19, 2018
cgen.c update copyright notices Jun 19, 2018
eval.c update copyright notices Jun 19, 2018
eval.html fix web terminal Jan 23, 2018
lex.c update copyright notices Jun 19, 2018
lib.ppr update copyright notices Jun 19, 2018
list.c update copyright notices Jun 19, 2018
macros.h update copyright notices Jun 19, 2018
module.c update copyright notices Jun 19, 2018
package.json upgrade jquery.terminal, use yarn Jun 11, 2017
parse.c update copyright notices Jun 19, 2018
popr improve number parsing Feb 1, 2018
popr-mode.el work on emacs mode and watch script May 31, 2017
poprc working on sum, fix stack.nip Jun 14, 2018
poprc-mode.el added poprc-mode.el Mar 25, 2015
primitive.c update copyright notices Jun 19, 2018
print.c update copyright notices Jun 19, 2018
rt.c update copyright notices Jun 19, 2018
rt_types.h update copyright notices Jun 19, 2018
special.c update copyright notices Jun 19, 2018
staging.ppr move length and some tests out of staging Jun 29, 2017
tests.ppr update copyright notices Jun 19, 2018
tests.txt remove vectors Apr 7, 2018
tok.c update copyright notices Jun 19, 2018
trace.c update copyright notices Jun 19, 2018
user_func.c update copyright notices Jun 19, 2018
yarn.lock fix web terminal Jan 23, 2018

README.md

Popr Compiler Build Status

This project is to implement a compiler for the Popr (previously Peg) language. The language has changed somewhat to support efficient compilation and type checking.

Please see this presentation for more information.

The following expressions can be evaluated online using the PoprC web version.

Here is a quick description of the language as it is currently. Lines beginning with ":" are user input, the following lines are output from the interpreter.

: 1 2 +
  3

Popr is a post-fix concatenative language. + is an operator that takes two integers and returns one. There are several similar operators, with the same meaning as in C: -, *, <, <=, ==, >, >=. Booleans are represented as the symbols True and False.

: 1 2 | 3 +
  4
  5
: 2 5 | dup 3 >= !
  5

| creates alternative execution paths. ! takes two values. If the second argument is False, the it fails, otherwise the first value is returned. These primitives provide a more general mechanism than if/else, similar to speculative execution, or Prolog inference.

: [ 1 2 + 3 4 + ] popr
  [ 1 2 + ] 7
: 1 [ 2 + ] pushl
  [ 1 2 + ]
: 1 [ 2 + ] pushl popr
  [] 3

[ ... ] denotes a quote, which can be used for constructing functions or for aggregating values. popr pops the rightmost element and forces evaluation. pushl takes its first argument and pushes it onto the left of the fragment. The two primitives can be combined to evaluate a fragment. Notice that Popr is lazy, and only reduces functions in quotes when required.

: 1 2 | dup
  1 1
  2 2
: 1 2 swap
  2 1
: 1 2 drop
  1

Some other primitives. dup duplicates a value; notice how it respects the constraints introduced by alternatives. swap swaps two values. drop drops a value.

 : 1 2 [3+] dip11
   4 2
 : 1 2 [3] dip12
   1 3 2
 : 1 3 2 [+] dip21
   4 2
 : [1] 2 pushr
   [ 1 2 ]

Some other functions.

License

The license for the Popr Compiler is GPL3. See LICENSE for more information.