Skip to content

1. rajiniPP: Language Specification

Aadhithya Sankar edited this page May 19, 2022 · 4 revisions

This document outlines the rajini++ language specification and syntax.

rajini++ Keywords and Symbols

Keyword Meaning
LAKSHMI START Program Starts
MAGIZHCHI Program Ends
DOT Print
AANDAVAN SOLLRAN Declare Variable
ARUNACHALAM SEIYARAN Set initial value
BHAJJI SAAPDU Assign Value
EN PEAR MANICKAM If
ENAKKU INNUR PEAR IRUKKU Else
KATHAM KATHAM EndIf/EndLoop
NAA <number> THADAVA SONNA <number> THADAVA SONNA MADHRI For Loop
BABA COUNTING STARTS While Loop
BLACK SHEEP break loop
Symbol Meaning
+ Sum
- Difference
/ Division
* Multiplication
% Modulo
> Greater Than
> Greater Than
>= Greater Than Equal To
< Lesser Than
<= Lesser Than Equal To
== Equal To
!= Not Equal To
{ Begin flow control block(conditional/loops)
{ End flow control block(conditional/loops)
; End Statement

Tokens

  • PGM_START: "LAKSHMI START"

  • PGM_END: "MAGIZHCHI"

  • PRINT: "DOT"

-SEMI_COLON: ;

-L_BRACE: {

-R_BRACE: }

-NUMBER: \d+(:?.\d+)?

-WORD: "[a-z_]+"

-STRING: ".*?"

-BOOL_TRUE: "True"

-BOOL_FALSE: "False"

-SUM: +

-SUB: -

-MUL: *

-DIV: /

-MOD: %

-GT: ">(?!=)"

-LT: "<(?!=)"

-GTE: ">="

-LTE: "<="

-EQ: "=="

-NEQ: "!="

-START_DECLARE: "AANDAVAN SOLLRAN"

-DECLARE: "ARUNACHALAM SEIYARAN"

-ASSIGN: "BHAJJI SAAPDU"

-DECLARE_ALT: ":="

-IF_COND: "EN PEAR MANICKAM"

-ELSE_COND: "ENAKKU INNURU PEAR IRUKKU"

-WHILE_LOOP: "BABA COUNTING STARTS"

-FOR_START: "NAA"

-FOR_RANGE_START: "THADAVA SONNA(?! MADHRI)"

-FOR_RANGE_END: "THADAVA SONNA MADHRI"

-END_BLOCK: "KATHAM KATHAM"

-BREAK_LOOP: "BLACK SHEEP"

-FUNC_DECLARE: "EN VAZHI THANI VAZHI"

-END_FUNC: "MARAKKADHINGA"

-FUNC_RETURN: "IDHU EPDI IRUKKU"

-FUNC_CALL: "CHUMMA ADHURUDHULA"

rajini++: BNF Productions

Simply put, the productions dictates the syntax of the language. More info about what productions are and how they are used in this article.

Program

ProgramParser parses complete rajini++ programs. The following productions are used:

  • program : functions main

  • main : PGM_START statements PGM_END

Functions

Productions that parse functions.

  • functions : functions function
              : 
    
  • function : FUNC_DECLARE func_name statements END_FUNC
    

Statement

Productions that parse statements.

  • statements : statements statement
               : 
    
  • statement : PRINT printexprs SEMI_COLON
              : START_DECLARE variable DECLARE expression SEMI_COLON
              : START_DECLARE variable DECLARE_ALT expression SEMI_COLON
              : variable ASSIGN expression SEMI_COLON
              : IF_COND logical_expression L_BRACE statements R_BRACE END_BLOCK SEMI_COLON
              : IF_COND logical_expression L_BRACE statements R_BRACE ELSE_COND L_BRACE statements R_BRACE END_BLOCK SEMI_COLON
              : FOR_START forvar FOR_RANGE_START forvar FOR_RANGE_END L_BRACE statements R_BRACE END_BLOCK SEMI_COLON
              : WHILE_LOOP expression L_BRACE statements R_BRACE END_BLOCK SEMI_COLON
              : FUNC_CALL func_name SEMI_COLON
              : variable FUNC_CALL func_name SEMI_COLON
              : FUNC_RETURN expression SEMI_COLON
    

Expressions

Productions to parse expressions.

  • expression : expression mathop expression
               : expression logicalop expression
               : SUB expression
               : SUM expression
               : NUMBER
               : STRING
               : BOOL_TRUE
               : BOOL_FALSE
               : WORD
    
  • logical_expression : expression logicalop expression

Operations

Productions dealing with operations between variables / expressions.

  •  mathop : SUM
            : SUB
            : MUL
            : DIV
            : MOD
    
  • logicalop : GT
              : LT
              : GTE
              : LTE
              : EQ
              : NEQ
    

Printing

Productions related to print statemtnt.

  • printexprs : printexprs expression
               : 
    

Other

Other productions not specific to a group

  • forvar : NUMBER
           : WORD
    
  • func_name: WORD
  • variable: WORD