-
Notifications
You must be signed in to change notification settings - Fork 20
2. rajinipp: The interpreter
Aadhithya Sankar edited this page May 17, 2022
·
4 revisions
The rajini++ code one writes is interpreted as executable python code, thanks to the rajinipp interpreter. In fact, it is the interpreter that is developed in this project. This page documents the exposed api of the interpreter.
-
rajinipp.runner
exposes the rajini++ interpreter to accessed from python scripts.
- The
rajinipp.runner.RppRunner
class allows access to the rajinipp interpreter - In fact, the
rajinipp.runner.RppRunner
function is used in the tests for the rajiniPP repository! -
rajinipp.runner.RppRunner
can in principle be used in any python script to execute rajini++ code.
-
rajinipp.runner.RppRunner.tokenize(code: str)
: tokenizes the input rajini++ code and returns the tokens. -
rajinipp.runner.RppRunner.exec(code: str, log_level:str="ERROR:")
: Executes the input rajini++ program code. -
rajinipp.runner.RppRunner.eval(code_line: str, log_level:str="ERROR:")
: evaluates the input rajini++ statement and returns the output.
Because the rajinipp interpreter is written completely in python, it is possible to run rajini++ code inside python scripts (experimental)!
Example Code:
<script src="https://gist.github.com/aadhithya/1e61d2af32fc77e24da9772a5b6022ba.js"></script>Output:
Hello, World from python!
Hello world from rajini++!
Executing 5+5 in rajini++
5 + 5 = 10.0
rajini++ • Created by Aadhithya Sankar • asankar.xyz