Giter Club home page Giter Club logo

hebrewpy's Introduction

HebrewPy

I dont know why would anyone need this, but this is just a very simple compiler/interpreter, that can run/compile hebrew code. Currently, one can interpret and run the code as python, or compile it into C++.

To run the code, one would need to call:

import HePyCompiler

compiler = HePyCompiler.Compiler( "sourcefile.something", debug=false, flip=true)
compiler.run()
  • this will run the code in python *
  • debug - prints some debug info, flip = mirrors the output *
  • code will be read from "sourcefile.something" *

To compile into Cpp file.

''' import HePyCompiler

compiler = HePyCompiler.Compiler( "sourcefile.something", debug=false) compiler.compile_cpp("outputfile.cpp") '''

  • this will rewrite/create a new file outputfile.cpp with the Cpp code *

What currently supported

  • Set/Initialize variables. (keyword ויהי)
    • ויהי שם_משתנה = ערך_כלשהו
  • Print. (keyword הדפס)
    • הדפס "משהו" + שם_משתנה
  • Supports +,-,/,* and or as well as ().
    • ויהיה איקס = 5/10+(33/(10/2))
    • Can add to string number, with will simply append it, and can combine strings by +.
  • if, else if, else, while ( אם, אחרת אם, אחרת, כל עוד )

Example of code:

ויהי א=30
כל עוד א > 0
	תדפיס "א = " + א
	אם א > 10
		תדפיס "א>10"
		אם א > 20
			תדפיס "וגם א>20 : " + א
			א=א-2
		אחרת
			תדפיס "וגם א<20 : " + א
			א = א-1
		-
		א=א-1
		תדפיס "סוף א>10 : " + א
	אחרת	אם א>5
		א = א-1
		תדפיס "א>5"
	אחרת
		תדפיס "א<5"
	-
	א=א - 1
-
  • We end a scope by the symbol -, scope starts after if,if else, else automaticaly.

Remark

The code can be easily modified to work with any language one simply needs to rename all accurances of keywords, for instance "אם" might be renamed to "check", and soo on, i will likely in the future add a file with keywords, so one can change the language to look diffrently, but with same format i guess.

python vs c++

There might be differences in behaviour for instance as python allows one to override existing variable with a value of a different type, code that does exactly that would work fine in python (i.e if we run compiler.run() ), but will return an uncompilable code for c++ (i.e compiler.compile_cpp("outputfile.cpp")).

hebrewpy's People

Contributors

mike-tr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.