Skip to content

An interpreted programming language written in java that uses recursive descent parsing

Notifications You must be signed in to change notification settings

LambdaAK/RGBScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RGBScript

RGBScript is a C-style, imperative programming language that supports basic types, variables, functions, and control structures.

This language gets its name from the fact that it outputs programs and program results in a colorful, fun way.


Types:
Arithmetic (Integer)
Boolean
String

EBNF Language Grammar

Terminal Definitions

STRING represents a sequence of UTF-8 encoded characters, ex: a, abc, abcdegfh

INT represents an integer in java, ex: 1, 125, 12345

Anything surrounded by single quotes is also a terminal, ex: '(' ')' 'and' 'or' '+'

Production Definitions

Arithmetic

Working with numbers using mathematical operations

arithmetic_expression ::= arithmetic_term addop arithmetic_expression | arithmetic_term

arithmetic_term ::= arithmetic_factor mulop arithmetic_term | arithmetic_factor

arithmetic_factor ::= INT | ( arithmetic_expression ) | - arithmetic_factor | arithmetic_factor powop arithmetic_factor | var_name | function_call

addop ::= '+' | '-'

mulop ::= '*' | '/' | '%'

power ::= '^'


Booleans

Working with truth-valued expressions, including boolean literals and numeric comparisons

atomic_boolean ::= 'true' | 'false'

boolean_expression ::= boolean_term 'or' boolean_expression | boolean_term

boolean_term ::= boolean_factor 'and' boolean_term | boolean_factor

boolean_factor ::= atomic_boolean | 'not' boolean_factor | '(' boolean_literal ')' | relation | var_name | function_call


Strings

The syntax for declaring and manipulating strings

string_expression ::= string_factor | string_factor '&' string_expression

string_factor ::= '"' STRING '"' | var_name | function_call


Functions

The syntax for calling and declaring functions

function ::= STRING

function_call ::= function '(' function_args ')' | function ( )

functionargs ::= function_arg (, function_arg)*

function_arg ::= expression


Variables

Declaring and assigning to variables

var_type ::= 'boolean' | 'int' | 'string' | 'typeless' | 'any'

var_name ::= STRING

var_decl ::= 'var' var_type var_name '<--' expression;

augmented_assignment_operator ::= '<--(+)' | '<--(-)' | '<--(*)' | '<--(/)' | '<--(%)' | '<--(&)'

assignment_operator ::= augmented_assignment_operator | '<--'

assignment ::= var_name assignment_operator expression ';'


Relations

Comparing numbers

relop ::= '>' | '<' | '>=' | '<=' | '==' | '!='

relation ::= arithmetic_expression relop arithmetic_expression


Control Structures

The general structure of a program

typeless_expression ::= var_name | function_call | '(' typeless_expression ')'

typed_expression ::= arithmetic_expression | boolean_literal | string_expression | typeless_expression

expression ::= typeless_expression | typed_expression

statement ::= function_call ';' | var_decl ';' | assignment ';' | 'terminate' ';'

if_block ::= if '(' boolean_literal ')' (statement | block) | if '(' boolean_literal ')' '{' (statement | block)* '}'

else_block ::= else (statement | block) | else '{' (statement | block)* '}'

conditional_block ::= if_block | if_block else_block

while_block ::= 'while' '(' boolean_literal ')' (statement | block) | 'while' '(' boolean_literal ')' '{' (statement | block)* '}'

block ::= conditional_block | while_block

program ::= (statement | block)*

About

An interpreted programming language written in java that uses recursive descent parsing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages