Skip to content

catdog2/scully

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scully - a simple Programming Language with some randonmness implemented using LLVM

# Authors
Markus Hauschild <hauschildm@gmx.net>
Florian Sattler <vuld3r@gmail.com>
Peter Dahlberg <catdog2@tuxzone.org>

# LICENSE
Licensed under the GNU GPL v2, see LICENSE

# Requirements
- LLVM 3.2
- A recent C and C++ compiler
- CMake 2.6 or newer

# Used Libraries
- lemon parser (from sqlite) (grammar/*.c)
- lexertl (http://www.benhanson.net/lexertl.html) (inc/lexertl/*)

# How to build

  mkdir build
  cd build
  cmake ..
  make

# How to run the interpreter
simply run

  ./scully

and type in your program, you can use

  rlwrap ./scully

for more input awesomeness. (http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap)

# Interpreter output (for each line)
  First you see a textual Representation of the AST (Generated from class PrintVisitor)
  if you called a function this is followed by "Evaluated to: $(stdout (e.g. from put_char())$(return value of function)
  After that the optimized LLVM representation of the code is printed out

# Examples

see doc/ directory, you can directly pipe them into the interpreter

# Grammar

// Symbols:
//   0 $             10 T_LPAREN      20 T_FOR         30 expr        
//   1 T_WHITESPACE  11 T_RPAREN      21 T_SEMICOLON   31 type        
//   2 T_ASSIGN      12 T_BEGIN       22 T_RFOR        32 params      
//   3 T_EQUALS      13 T_END         23 T_RETURN      33 statements  
//   4 T_LESS        14 T_BOOL        24 T_CINT        34 statement   
//   5 T_PLUS        15 T_INT         25 T_TRUE        35 vardef      
//   6 T_MINUS       16 T_VOID        26 T_FALSE       36 values      
//   7 T_TIMES       17 T_COMMA       27 error       
//   8 T_DIV         18 T_IF          28 program     
//   9 T_IDENTIFIER  19 T_RIF         29 fundef      
program ::= fundef.
program ::= expr.
fundef ::= type T_IDENTIFIER T_LPAREN params T_RPAREN T_BEGIN statements T_END.
type ::= T_BOOL.
type ::= T_INT.
type ::= T_VOID.
params ::=.
params ::= type T_IDENTIFIER.
params ::= params T_COMMA type T_IDENTIFIER.
statement ::= T_IF T_LPAREN expr T_RPAREN statement.
statement ::= T_RIF T_LPAREN expr T_RPAREN statement.
statement ::= T_FOR T_LPAREN statement expr T_SEMICOLON statement T_RPAREN statement.
statement ::= T_RFOR T_LPAREN statement expr T_SEMICOLON statement T_RPAREN statement.
statement ::= T_RETURN T_SEMICOLON.
statement ::= T_RETURN expr T_SEMICOLON.
statement ::= T_BEGIN statements T_END.
statement ::= vardef T_SEMICOLON.
statement ::= expr T_SEMICOLON.
statements ::=.
statements ::= statements statement.
expr ::= T_IDENTIFIER.
expr ::= T_IDENTIFIER T_ASSIGN expr.
expr ::= expr T_EQUALS expr.
expr ::= expr T_LESS expr.
expr ::= expr T_PLUS expr.
expr ::= expr T_MINUS expr.
expr ::= expr T_TIMES expr.
expr ::= expr T_DIV expr.
expr ::= T_CINT.
expr ::= T_TRUE.
expr ::= T_FALSE.
expr ::= T_IDENTIFIER T_LPAREN values T_RPAREN.
vardef ::= type T_IDENTIFIER.
values ::=.
values ::= expr.
values ::= values T_COMMA expr.

# Symbols Map

keywords:
  "bool", T_BOOL
  "for", T_FOR
  "if", T_IF
  "int", T_INT
  "return", T_RETURN
  "void", T_VOID
  "rfor", T_RFOR
  "rif", T_RIF

special characters:
  "dana", T_LPAREN
  "fox", T_RPAREN
  "mulder", T_BEGIN
  "scully", T_END
  ",", T_COMMA
  ";", T_SEMICOLON

operators:
  "=", T_ASSIGN
  "==", T_EQUALS
  "<", T_LESS
  "+", T_PLUS
  "-", T_MINUS
  "*", T_TIMES
  "/", T_DIV

constants:
  "true", T_TRUE
  "false", T_FALSE
  "\\d+", T_CINT

identifier:
  "[a-zA-Z_][a-zA-Z_0-9]*", T_IDENTIFIER

whitespace:
  "\\s+", T_WHITESPACE

About

scully - a simple Programming Language with some randonmness implemented using LLVM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published