The Déjà Vu programming language
C Python C++
Switch branches/tags
Latest commit 0cbf11c Aug 12, 2014 @gvx Update usage string
Permalink
Failed to load latest commit information.
docs Add documentation folder Dec 17, 2013
vm Update usage string Aug 12, 2014
.gitignore Add compiler written in Déjà Vu Oct 7, 2013
GRAMMAR.bnf Updates GRAMMAR.bnf Oct 13, 2012
LICENSE Adds ISC license Jan 16, 2013
README.md Update README Nov 7, 2013
annotate.py Adds JMPEQ, JMPNE and ENTER_ERRHAND to annotate.py Sep 27, 2012
bytecode.py Adds opcode for CALL Feb 28, 2013
collect.py Adds fraction literals to compiler Sep 20, 2012
context.py Add escape sequences for literal strings Nov 6, 2013
convert.py Adds opcode for CALL Feb 28, 2013
depgraph.py Makes tools compatible with Py3K Oct 24, 2013
dis.py Add escape sequences for literal strings Nov 6, 2013
dvasm.py Add in-line literals for assembler Dec 17, 2013
dvc.py Makes tools compatible with Py3K Oct 24, 2013
errors.py Adds inline labdas Sep 18, 2012
flatten.py Introduce method syntax for function definitions Nov 6, 2013
func.py Rewrite progress + removes ArgumentList in favour of list of strings Mar 17, 2011
gencompilerc.py Add compiler written in Déjà Vu Oct 7, 2013
genstdc.py Swaps out old string implementation for new one Mar 21, 2013
ifelse.py First steps towards freedom from Python call stack Mar 9, 2011
loop.py Adds repeat statement Apr 28, 2012
nodes.py Adds fraction literals to compiler Sep 20, 2012
parse.py Removes interactive part of parse.py Sep 14, 2012
strquot.py Whoops, forgot to add strquot.py Dec 17, 2013
trycatch.py Adds proper try/catch-statements to language Sep 27, 2012
v2a.py Fix label-related bug in disassembler Dec 17, 2013

README.md

Déjà Vu

It is a programming language. Stack-based. Semi-functional. Backwards. Inspired by Python and Forth. I'm talking about Déjà Vu.

Setting up the virtual machine

$ cd vm/
$ make
$ cd ..

Running things

Assuming you have a module called yourfile.deja, you can compile and run it with:

$ vm/vu yourfile.deja

Examples

Hello world

!print "Hello world!"

Fibonacci

fib a:
	if > 1 a:
		fib - 1 a
		fib - 2 a
		+
	elseif = a 1:
		1
	else:
		0

Quine

"!print !. dup"
!print !. dup

Fractions

. * 1/3 3/2 # prints 1/2

Grammar

If you know what BNF is, here's the one for Déjà Vu:

Program ::= <Block>*

Block ::= <Head> ":" <NewLine>+ (<Indentation> <Block>)+
        | <Line> <NewLine>+
        | <IfBlock>
        | <TryBlock>

IfBlock ::= "if" <Space> <Line> ":" <NewLine>+ (<Indentation> <Block>)+
            ("elseif" <Space> <Line> <Space>? ":" <NewLine>+ (<Indentation> <Block>)+)*
            ("else" <Space>? ":" <NewLine>+ (<Indentation> <Block>)+)?

TryBlock ::= "try" <Space>? ":" <NewLine>+ (<Indentation> <Block>)+
             ("catch" (<Space> <ProperWord>)+ <Space>? ":" <NewLine>+ (<Indentation> <Block>)+)*

Head ::= "while" <Space> <Line>
       | "for" <Space> <ProperWord> (<Space> <Line>)? <Space>?
       | "repeat" <Space> <Line>
       | "func" <Space> <ProperWord> <Arguments>
       | "local" <Space> <ProperWord> <Arguments>
       | "labda" <Arguments>
       | <ProperWord> <Arguments>

Indentation ::= (" " | <Tab>)*

Line ::= (<Word> (<Space> <Word>)*)? <Space>?

Arguments ::= (<Space> <ProperWord>)* <Space>?

Space ::= (" " | <Tab>)+

Word ::= ProperWord
       | Get
       | Identity
       | String
       | Number
       | Fraction

Get ::= "@" <ProperWord>?

Identity ::= ":" <ProperWord>?

ProperWord ::= <Char>+

String ::= '"' <StringChar>* '"'

Number ::= '-'? <Digits> ('.' <Digits>)?

Fraction ::= '-'? <Digits> '/' <Digits>

Digits ::= ('0'..'9')+

Char ::= any non-whitespace, non-# character

StringChar ::= any character other than a double quote