Semester Project for CSCI 3200, Programming Languages. Create a new programming language, parse it, translate it to python and compile/execute.
HebrewScript is an odd combination of Python and Java. Instead of the Roman alphabet this language uses the Hebrew alphabet.
The language is read right to left, top to bottom. Typing the language follows all the conventions of typing in Hebrew. The symbols like, brackets, parenthesis, etc... are typed using the reverse. For example, the open parenthesis is typed using the closed parenthesis button. It is best to familiarize yourself with how Hebrew is typed before attempting to write programs. There are many instances that the line you are typing appears incorrect until you are finished typing the line.
The best way to understand the language is to look at the translations outlined in the Translations section. Statement lines such as if, do, and user defined functions end with a colon (':').
block is the code executed within a function.
(parameter) function_type:
block
end
do:
block
condition while
end
condition if:
block
end
All translations were done using Google Translate. The Hebrew translation of a word is not always a direct translation. As with most things when translated, there is not always one way to translate.
if - "אם"
print("Hello World") - ('שלום עולם')הדפס
do - עשה:
while - בעוד
end - סוף
define user_function_name(parameter): - להגדיר פ(מ):
return - לחזור
execute{thing to be executed} - {ש}לבצע
Outlined below are all the characters accepted as part of HebrewScript's alphabet. It contains the Hebrew alphabet, minus some vowels, and a few characters. Different fonts can make characters look drastically different.
Not in any particular order:
" ' " "ף" "א" "ב" "ג" "ך" "ח" "ו" "ז" "ה" "ס" "י" "כ" "ל" "מ" "נ" "ם" "ץ" "פ" "ע" "ק" "ר" "ש" "ת" "ד" "_" "ז" "צ"
Running the sample programs is as simple as:
- Run the main.py file
- Select a program to run using the corresponding number.
- Output:
- The output of the program is printed to the terminal.
- The following files can be found in the
Output
folder- The original HebrewScript program is written to the
program.txt
file. - The parse tree is written to the
parse_tree.txt
file. - The python interpretation that is executed is written to the
python.txt
file.
- The original HebrewScript program is written to the
NOTE: If an error occurs, simply rerun the program and it should work the second or third time. The errors only occur with programs 2 and 5. This may be due to inconsistancies with how Lark interprets the Hebrew letters.
- While loop that increments a counter 0 to 8.
- Fibonacci Sequence for 9.
- Do basic math problems:
- 10 + 9
- 10 * 9
- 100 / 25
- 100 - 25
- REMOVED - Print the word דלג to the screen
- Find the Lucas Number for 9.
- REMOVED - Concatination of strings.
- REMOVED - String multiplication of a string to create a larger string
- Programs 4,6,7 were removed due to an error printing the Hebrew characters.
- Anything containing a Hebrew character cannot be printed to the screen.