├── .gitignore ├── LICENSE ├── MODI ├── README.md ├── examples ├── GDP.chai ├── arithmetic.chai ├── election.chai ├── factorial.chai ├── fibo.chai ├── mandir.chai ├── modi.chai ├── result.chai ├── sanskaar.chai ├── scam.chai ├── scheme.chai ├── swapscam.chai └── voter.chai ├── modiscript ├── __init__.py ├── api.py ├── lexer.py ├── parser.py └── utils.py ├── now.json └── website ├── requirements.txt ├── ui ├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ ├── android-icon-144x144.png │ ├── android-icon-192x192.png │ ├── android-icon-36x36.png │ ├── android-icon-48x48.png │ ├── android-icon-72x72.png │ ├── android-icon-96x96.png │ ├── apple-icon-114x114.png │ ├── apple-icon-120x120.png │ ├── apple-icon-144x144.png │ ├── apple-icon-152x152.png │ ├── apple-icon-180x180.png │ ├── apple-icon-57x57.png │ ├── apple-icon-60x60.png │ ├── apple-icon-72x72.png │ ├── apple-icon-76x76.png │ ├── apple-icon-precomposed.png │ ├── apple-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon-96x96.png │ ├── favicon.ico │ ├── index.html │ ├── ms-icon-144x144.png │ ├── ms-icon-150x150.png │ ├── ms-icon-310x310.png │ └── ms-icon-70x70.png ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── codes.js │ ├── components │ │ └── home.vue │ ├── main.js │ └── plugins │ │ └── vuetify.js └── vue.config.js └── web.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .vscode/ 3 | env/ 4 | .now 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Vishal Panjeta, Shishira R Maiya and Tilak S Naik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MODI: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | 6 | from modiscript.api import ModiScript 7 | from modiscript.utils import ErrorHandler, FNF, usage 8 | 9 | DEBUG = False 10 | 11 | 12 | def main(): 13 | if len(sys.argv) < 2 or '-h' in sys.argv or '--help' in sys.argv: 14 | usage() 15 | 16 | filename = sys.argv[-1] 17 | # filename = "modi.chai" 18 | if '-d' in sys.argv or '--debug' in sys.argv: 19 | global DEBUG 20 | DEBUG = True 21 | 22 | # check existence 23 | if not os.path.isfile(filename): 24 | raise ErrorHandler(FNF, filename) 25 | # execute 26 | ms = ModiScript(DEBUG) 27 | ms.execute(filename) 28 | 29 | 30 | if __name__ == '__main__': 31 | try: 32 | main() 33 | except ErrorHandler as e: 34 | print(e) 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ModiScript 2 | Acche din aa gaye 3 | Try the script in the [ModiScript web UI](https://modiscript.netlify.com/) 4 | 5 | ## Vision 6 | A Programming language is a wonderful medium of communication between man and machine. Many such languages are created, keeping in mind the comfort of the programmer. Such languages fulfill the computational needs of the world and serve their purpose. Somewhere in the midst of all this, the “fun” side of programming is lost. 7 | Our project, “Modi Script” is one such esoteric language created with the sole intention of making use of quotes by our beloved PM Narendra Modi. The star feature of this language is that the language consists entirely of remarkable statements made by the PM. The language is dynamically typed and turing complete, sprinkled with words of wisdom by our PM! 8 | 9 | ## Features 10 | This scripting language includes some "ideas" of Shri Narendra Modi. 11 | * No import of code is allowed, we have to support him in Make in India. 12 | * No comments are allowed in code, everything should be clean as per Swachh Bharat Abhiyaan. 13 | * No redundant variables allowed, 'less government more governance.' 14 | * Like his speeches, all codes should start with mitrooon 15 | * All codes should end with acche din aa gaye, otherwise it's congress rule error. 16 | * The programming language is totally case insensitive because we should not believe discrimination based on higher or lower castes/cases. 17 | * No floating point numbers allowed, you can either be right front or left front, there is no mid-way. 18 | * you can use the --help flag for very discreet help. 19 | 20 | 21 | ## Installation 22 | To install, download the repo using: 23 | ```bash 24 | git clone https://github.com/VPanjeta/ModiScript 25 | ``` 26 | Then add ModiScript to your PATH as: 27 | 1. Temporary: Write `export PATH=$PATH:/path/to/ModiScript` to terminal. 28 | 2. Permanent: Append `export PATH=$PATH:/path/to/ModiScript` to the end of your `~/.bashrc` file. 29 | And then type 30 | ```bash 31 | source ~/.bashrc 32 | ``` 33 | ## Execution 34 | Write code in file with extension .chai 35 | For execution type MODI filename.chai 36 | 37 | ## Syntax and Grammar 38 | Arithmetic, relational and logical operators can be used in their raw form as defined in c/c++ (i.e. '+' for addition '-' for subtraction '&&' for logical and '||' for logical or and so on..) 39 | Modi-fied operators 40 | * `sach` for True 41 | * `jhoot` for False 42 | * `plus` for addition 43 | * `substract` for subtraction 44 | * `taimes` for multiplication 45 | * `break` for division 46 | * `modi` for mod 47 | * `kam` for less than 48 | * `zyada` for greater than 49 | * `barabar` for equal to 50 | * `aur` for logical AND 51 | * `ya` for logical OR 52 | 53 | ## Flow of Control 54 | * { } define a block as in any other programming language. 55 | * if is defined as agar and else as nahi toh. if else ladder can be defined as agar (condition) { } nahi toh agar (condition) { } nahi toh{ }. 56 | * Looping constructs can be defined using jab tak condition hai { } (be careful here, we have been going according to hindi grammar that dictates the loop will exit when the condition is true, thus the loop executes till the condition is false not true) 57 | 58 | ## General Syntax 59 | * Any quote in double or single inverted commas is taken as a string constant. eg "Modiji ka seena 56 inch ka hai". 60 | * Assignments to a variable can be done using hai keyword, x = y can be depicted as x y hai, or congress scamster hai . 61 | * The use of the word "hai" is optional so the statement can be defined as BJP winner which translates to BJP = winner and hai can be appended to end of any line to make it more grammarly suitable to hindi. 62 | * Output to STDOUT can be given using bhaiyo aur behno. bhaiyo aur behno "Hum UP me sarkaar bana chuke hai." will print "Hum UP me sarkaar bana chuke hai." 63 | * Input from STDIN can be taken using mann ki baat. mann ki baat RSS will take input into a variable named RSS. 64 | * Any excessive words defined in a line outside the scope of any operators or syntax will be neglected so you can write pure hindi codes and make them grammatically correct and give a pure Hindi Code demo in UN Assembly. 65 | 66 | ## Example Code 67 | ``` 68 | Mitrooon 69 | agar baat sach hai 70 | bhaiyo aur behno "Modi sabse achhe pradhan mantri hai." 71 | nahi toh 72 | bhaiyo aur behno "Rahul Gandhi ko PM banaiye" 73 | Achhe din aa gaye 74 | ``` 75 | 76 | Output: 77 | "modi sabse achhe pradhan mantri hai." 78 | 79 | Example codes can be found in `/example`. 80 | 81 | # Creators 82 | Ideas and Contributions for alpha version implemented by 83 | * Vishal Panjeta [@VPanjeta](https://vpanjeta.github.io) 84 | * Tilak S Naik [@TilakSN](https://github.com/TilakSN) 85 | * Shishira R Maiya [@abhyantrika](https://github.com/abhyantrika) 86 | 87 | Web UI over flask service implemented by 88 | * Daksh Miglani [@DakshMiglani](https://github.com/DakshMiglani) 89 | 90 | * You are welcome if you feel the need to contribute. Just clone the repo and send a pull request! 91 | -------------------------------------------------------------------------------- /examples/GDP.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | GDP 3 hai 3 | jab tak GDP 8 se jyada { 4 | bhaiyo aur behno "Bharat ki GDP badhkar" 5 | bhaiyo aur behno GDP 6 | bhaiyo aur behno "hogayi hai" 7 | GDP (GDP+1) hai 8 | } 9 | acche din aa gaye -------------------------------------------------------------------------------- /examples/arithmetic.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | x 100 hai 3 | y (200 plus x) * 100 hai 4 | jab tak x y se zyada hai aur x se kam 100000 hai 5 | x x plus x hai 6 | bhaiyo aur behno x 7 | acche din aa gaye -------------------------------------------------------------------------------- /examples/election.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | bhaiyo aur behno "lok sabha elections" 3 | bhaiyo aur behno "1 dabaiye BJP ke liye" 4 | bhaiyo aur behno "2 dabaiye INC le liye" 5 | bhaiyo aur behno "0 dabaiye result ke liye" 6 | bhaiyo aur behno "Apna vote dijiye" 7 | BJPvotes 0 hai 8 | INCvotes 0 hai 9 | mann ki baat nambar 10 | jab tak nambar barabar 0 hai{ 11 | agar nambar barabar 1 hai{ 12 | BJPvotes BJPvotes + 1 hai 13 | } 14 | nahi toh agar nambar barabar 2 hai{ 15 | INCvotes INCvotes + 1 hai 16 | } 17 | nahi toh{ 18 | bhaiyo aur behno "galat button dabaya" 19 | } 20 | bhaiyo aur behno "Apna vote dijiye" 21 | mann ki baat nambar 22 | } 23 | 24 | agar BJPvotes INCvotes se zyada{ 25 | bhaiyo aur behno "sarkar bjp ki banegi" 26 | bhaiyo aur behno "acche din aa gaye" 27 | } 28 | nahi toh agar INCvotes BJPvotes se zyada{ 29 | bhaiyo aur behno "sarker inc ki banegi" 30 | bhaiyo aur behno "acche din abhi door hai" 31 | } 32 | nahi toh{ 33 | bhaiyo aur behno "re elections honge" 34 | } 35 | acche din aa gaye 36 | -------------------------------------------------------------------------------- /examples/factorial.chai: -------------------------------------------------------------------------------- 1 | mitroon 2 | factorial 1 hai 3 | i 1 hai 4 | bhaiyo aur behno "ek nambar do" 5 | mann ki baat nambar 6 | agar nambar 0 se kam hai 7 | bhaiyo aur behno "nakaratmak sankhyao ka factorial nai hota bhaiyo aur behno par mujhe sirf 50 din dijiye" 8 | nahi toh { 9 | jab tak i nambar se zyada hai { 10 | factorial factorial taimes i hai 11 | i i plus 1 hai 12 | } 13 | bhaiyo aur behno nambar 14 | bhaiyo aur behno "ka factorial" 15 | bhaiyo aur behno factorial 16 | bhaiyo aur behno "hai" 17 | } 18 | acche din aa gaye 19 | -------------------------------------------------------------------------------- /examples/fibo.chai: -------------------------------------------------------------------------------- 1 | mitroon 2 | bhaiyo aur behno "ek nambar do" 3 | mann ki baat nambar 4 | dusra 1 hai 5 | pehla dusra hai 6 | jab tak nambar 1 se kam { 7 | ekaur pehla plus dusra 8 | pehla dusra hai 9 | dusra ekaur 10 | nambar nambar - 1 hai 11 | bhaiyo aur behno pehla hai 12 | } 13 | bhaiyo aur behno "ye hai fibonacci nambars" 14 | ache din aa gaye -------------------------------------------------------------------------------- /examples/mandir.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | UP "BJP governed state hai" 3 | SP "opposition me hai" 4 | agar ye sach hai 5 | bhaiyo aur behno "Mandir wahin banayenge" 6 | nahi toh 7 | bhaiyo aur behno "Mandir to wahin banega" 8 | achhe din aa gaye -------------------------------------------------------------------------------- /examples/modi.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | agar jhoot hai toh 3 | bhaiyo aur behno "Hello World!!!" 4 | nahi toh 5 | bhaiyo aur behno "Namaskar" 6 | acche din aa gaye -------------------------------------------------------------------------------- /examples/result.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | BJP 324 hai 3 | SP 47 hai 4 | bhaiyo aur behno "up results" hai 5 | agar BJP se jyada SP hai 6 | bhaiyo aur behno "Pappu aur Akhilesh jeete" 7 | nahi toh 8 | bhaiyo aur behno "Yogi ki jeet hui" hai 9 | achhe din aa gaye -------------------------------------------------------------------------------- /examples/sanskaar.chai: -------------------------------------------------------------------------------- 1 | mitroon 2 | 3 | bhaiyo aur behno "bhaiyo aur behno, Congress toh nahi kar paayi" 4 | bhaiyo aur behno "lekin main aapko sanskaari(prime) numbers k baare main bata sakta hun" 5 | 6 | mann ki baat number 7 | i 2 hai 8 | sanskaar sach hai 9 | 10 | jab tak i kam number - 1 hai { 11 | agar number modi i barabar 0 hai { 12 | sanskaar jhoot hai 13 | } 14 | i i plus 1 hai 15 | } 16 | 17 | agar sanskaar barabar sach hai { 18 | bhaiyo aur behno "ye sanskaari h" 19 | } nahi toh { 20 | bhaiyo aur behno "ye sanskaari nahi h" 21 | } 22 | 23 | achhe din aa gaye -------------------------------------------------------------------------------- /examples/scam.chai: -------------------------------------------------------------------------------- 1 | mitrooon 2 | itne 1 hai 3 | jab tak itne 100 se zyada{ 4 | bhaiyo aur behno "Congress ne " hai 5 | bhaiyo aur behno itne hai 6 | bhaiyo aur behno "crore ka scam kiya" 7 | itne (itne+1) hai 8 | } 9 | achhe din aa gaye -------------------------------------------------------------------------------- /examples/scheme.chai: -------------------------------------------------------------------------------- 1 | Mitrooon 2 | bhaiyo aur behno "Jawano ke liye 1 dabaye" 3 | bhaiyo aur behno "Kisano ke liye 2 dabaye" 4 | bhaiyo aur behno "Musalman ke liye 3 dabaye" 5 | mann ki baat nambar 6 | agar nambar barabar 1 hai{ 7 | bhaiyo aur behno "1986 se atake pade OROP mango ko pura kiya" 8 | bhaiyo aur behno "Har tyohar ko Jawano ke beech manaya" 9 | bhaiyo aur behno "Surgical strike ki permission deke Jawaan ka samman badhaya" 10 | } 11 | nahi toh agar nambar barabar 2 hai { 12 | bhaiyo aur behno "UP me sammaniya Yogi ji ke netrutva ke neeche Ganna kissano ko unke ganne ka upyukt daam dilaya" 13 | bhaiyo aur behno "Karj maafi karke arthvyavastha pe bhaar daalne ke bajaye Mudra Loan Yojana se 2022 tak kissano ki aay doguni karne ka lakshya rakha" 14 | bhaiyo aur behno "Ujwala gas yojana dwara har gareeb kisaan ke ghar me Gas cylinder ki uplabdhi karayi" 15 | bhaiyo aur behno "Awaas yojana ke tehat keval 7 lakh ke andar ghar dilaye evam subsidy bhi" 16 | bhaiyo aur behno "Aaaj ke naye India me Aayushman bharat ke yojana ke tehat gareeb se gareeb kissan apne parivar ko muft me sarkari aspatal me illaj karva sakta hai" 17 | } 18 | 19 | nahi toh agar nambar barabar 3 hai { 20 | 21 | bhaiyo aur behno "5 crore muslim yuvao ke liy Scholarship grant ki manjuri kari sarkar banne ke 10 din ke anadar" 22 | bhaiyo aur behno "Madarso ko puri tarah se re-model karke Muslalman garreb bachho ko acchi se acchi shiksha prapt karwaye jaane ka plan taiyar" 23 | 24 | } 25 | nahi toh { 26 | bhaiyo aur behno "Bharat ko New India banakar aazadi ke 75th saalgirah par 125 crore deshwasiyo ko taufa dene ka drudh sankalp kiya." 27 | } 28 | achhe din aa gaye 29 | -------------------------------------------------------------------------------- /examples/swapscam.chai: -------------------------------------------------------------------------------- 1 | Mitrooon 2 | 3 | pehlaNambar 5 hai 4 | dusraNambar 10 hai 5 | 6 | bhaiyo aur behno "Pehla Nambar " 7 | bhaiyo aur behno pehlaNambar 8 | bhaiyo aur behno "hai, aur Dusra Nambar " 9 | bhaiyo aur behno dusraNambar 10 | bhaiyo aur behno "hai." 11 | 12 | teesraNambar pehlaNambar hai 13 | pehlaNambar dusraNambar hai 14 | dusraNambar teesraNambar hai 15 | 16 | bhaiyo aur behno "Congress k iss scam k baad Pehla Nambar " 17 | bhaiyo aur behno pehlaNambar 18 | bhaiyo aur behno "hai, aur Dusra Nambar " 19 | bhaiyo aur behno dusraNambar 20 | bhaiyo aur behno "hai." 21 | 22 | Acche din aa gaye 23 | -------------------------------------------------------------------------------- /examples/voter.chai: -------------------------------------------------------------------------------- 1 | Mitrooon 2 | 3 | bhaiyo aur behno "apna umar batao" 4 | mann ki baat umar 5 | 6 | bhaiyo aur behno "tum bataye" 7 | bhaiyo aur behno umar 8 | 9 | agar umar 18 se zyada hai 10 | bhaiyo aur behno "aap vote de sakte hai" 11 | nahi toh 12 | bhaiyo aur behno "aap abhi chote hai" 13 | 14 | Achhe din aa gaye -------------------------------------------------------------------------------- /modiscript/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ["api", "utils"] 2 | -------------------------------------------------------------------------------- /modiscript/api.py: -------------------------------------------------------------------------------- 1 | from .lexer import Lexer 2 | from .parser import Parser 3 | 4 | 5 | class ModiScript: 6 | def __init__(self, debug=False): 7 | self.debug = debug 8 | 9 | def _compile_file(self, value, value_type="filename"): 10 | lex_out = Lexer(value, value_type).analyze() 11 | if self.debug and value_type == "filename": 12 | filename = value 13 | with open(filename.split('.', 1)[0] + ".txt", "w") as f: 14 | print(*lex_out, sep='\n', file=f) 15 | parse_out = Parser(lex_out).parse() 16 | if self.debug and value_type == "filename": 17 | with open(filename.split('.', 1)[0] + ".py", "w") as f: 18 | import ast 19 | print(ast.dump(parse_out), file=f) 20 | return compile(parse_out, "", "exec") 21 | 22 | def execute(self, value, value_type="filename"): 23 | ast_module = self._compile_file(value, value_type) 24 | exec(ast_module) 25 | -------------------------------------------------------------------------------- /modiscript/lexer.py: -------------------------------------------------------------------------------- 1 | from .utils import LEX, ErrorHandler, ERROR, CONGRESS_RULE, STARTING_TROUBLE, MISQUOTE, WORDS 2 | import re 3 | import sys 4 | 5 | mitrooon = re.compile(r'^mith?roo?o?n?$') 6 | acche = re.compile(r'^ac[ch]?hee?$') 7 | barabar = re.compile(r'^bara+bar$') 8 | sach = re.compile(r'^sac[ch]?h$') 9 | jhoot = re.compile(r'^jh?(oo|u)t$') 10 | 11 | 12 | class Lexer: 13 | def __init__(self, value, value_type="filename"): 14 | self.contents = [] 15 | if value_type == "filename": 16 | with open(value) as f: 17 | self.contents = list(map(lambda x: x.lower(), f.readlines())) 18 | else: 19 | self.contents = value.lower().split("\n") 20 | self.stack = [] 21 | self.clear = False 22 | 23 | @staticmethod 24 | def lexeme(lex, value=None, line=0, offset=0): 25 | return locals() 26 | 27 | @staticmethod 28 | def normalize(word): 29 | if word in WORDS: 30 | word = WORDS[word] 31 | elif mitrooon.search(word): 32 | word = 'mitrooon' 33 | elif acche.search(word): 34 | word = 'acche' 35 | elif barabar.search(word): 36 | word = 'barabar' 37 | elif sach.search(word): 38 | word = 'sach' 39 | elif jhoot.search(word): 40 | word = 'jhoot' 41 | return word 42 | 43 | def _push(self, *lex): 44 | self.stack.append(lex) 45 | self.clear = True 46 | 47 | def on_top(self, *lex): 48 | i = len(self.stack) - 1 49 | for l in lex[::-1]: 50 | if i < 0 or self.stack[i][:2] != l: 51 | return False 52 | i -= 1 53 | return True 54 | 55 | def pop(self): 56 | if self.stack: 57 | return self.stack.pop() 58 | raise ErrorHandler(ERROR, 'Empty pop') 59 | 60 | @staticmethod 61 | def _is_var(lex, value): 62 | return lex['lex'] == LEX['var'] and lex['value'] == value 63 | 64 | def analyze(self): 65 | lexer = self._analyze_lexemes() 66 | lex = next(lexer) 67 | if not Lexer._is_var(lex, 'mitrooon'): 68 | raise ErrorHandler(STARTING_TROUBLE) 69 | lexemes = list(lexer) 70 | end = 'acche din aa gaye'.split() 71 | try: 72 | while end: 73 | if not Lexer._is_var(lexemes.pop(), end.pop()): 74 | raise ErrorHandler(CONGRESS_RULE) 75 | except IndexError: 76 | raise ErrorHandler(CONGRESS_RULE) 77 | return lexemes 78 | 79 | def _analyze_lexemes(self): 80 | """ 81 | Identify lexemes and return tokens. 82 | """ 83 | num = 0 84 | self.stack = [] 85 | self.clear = False 86 | for line in self.contents: 87 | num += 1 88 | offset = 0 89 | length = len(line) 90 | while offset < length: 91 | token = line[offset] 92 | if self.clear: 93 | for lex in self.stack: 94 | yield Lexer.lexeme(*lex) 95 | self.stack = [] 96 | self.clear = False 97 | elif token.isspace(): 98 | offset += 1 99 | elif line[offset: offset + 2] in ('==', '&&', '||', '<=', '>=', '!='): 100 | self._push(LEX[line[offset: offset + 2]], None, num, offset) 101 | offset += 2 102 | elif token in '+-*/%(){}=<>!': 103 | self._push(LEX[token], None, num, offset) 104 | offset += 1 105 | elif token.isdigit(): 106 | n = '' 107 | o = offset 108 | while o < length and line[o].isdigit(): 109 | n += line[o] 110 | o += 1 111 | self._push(LEX['num'], int(n), num, offset) 112 | offset = o 113 | elif token.isalpha(): 114 | w = '' 115 | o = offset 116 | while o < length and line[o].isalpha(): 117 | w += line[o] 118 | o += 1 119 | w = Lexer.normalize(w) 120 | if w == 'agar': 121 | self._push(LEX['if'], None, num, offset) 122 | elif w == 'toh' and self.on_top((LEX['var'], 'nahi')): 123 | _, _, lex_line, lex_offset = self.pop() 124 | self._push(LEX['else'], None, lex_line, lex_offset) 125 | elif w == 'toh': 126 | self._push(LEX['then'], None, num, offset) 127 | elif w == 'tak' and self.on_top((LEX['var'], 'jab')): 128 | _, _, lex_line, lex_offset = self.pop() 129 | self._push(LEX['until'], None, lex_line, lex_offset) 130 | elif w == 'behno' and self.on_top((LEX['var'], 'bhaiyo'), (LEX['&&'], None)): 131 | self.pop() 132 | _, _, lex_line, lex_offset = self.pop() 133 | self._push(LEX['print'], None, lex_line, lex_offset) 134 | elif w == 'baat' and self.on_top((LEX['var'], 'mann'), (LEX['var'], 'ki')): 135 | self.pop() 136 | _, _, lex_line, lex_offset = self.pop() 137 | self._push(LEX['input'], None, lex_line, lex_offset) 138 | elif w == 'plus': 139 | self._push(LEX['+'], None, num, offset) 140 | elif w == 'substract': 141 | self._push(LEX['-'], None, num, offset) 142 | elif w == 'taimes': 143 | self._push(LEX['*'], None, num, offset) 144 | elif w == 'break': 145 | self._push(LEX['/'], None, num, offset) 146 | elif w == 'modi': 147 | self._push(LEX['%'], None, num, offset) 148 | elif w == 'kam': 149 | self._push(LEX['<'], 'word', num, offset) 150 | elif w == 'zyada': 151 | self._push(LEX['>'], 'word', num, offset) 152 | elif w == 'barabar': 153 | self._push(LEX['=='], 'word', num, offset) 154 | elif w == 'aur': 155 | self._push(LEX['&&'], None, num, offset) 156 | self.clear = False 157 | elif w == 'ya': 158 | self._push(LEX['||'], None, num, offset) 159 | elif w == 'hai': 160 | self._push(LEX['hai'], None, num, offset) 161 | elif w == 'se': 162 | pass 163 | elif w == 'sach': 164 | self._push(LEX['true'], None, num, offset) 165 | elif w == 'jhoot': 166 | self._push(LEX['false'], None, num, offset) 167 | else: 168 | self._push(LEX['var'], w, num, offset) 169 | self.clear = False 170 | offset = o 171 | elif token == '"' or token == "'": 172 | w = '' 173 | o = offset + 1 174 | while o < length and line[o] != token: 175 | if line[o] == '\\': 176 | o += 1 177 | w += line[o] 178 | o += 1 179 | if o == length: 180 | raise ErrorHandler(MISQUOTE, line) 181 | self._push(LEX['str'], w, num, offset) 182 | offset = o + 1 183 | else: 184 | self._push(LEX['sym'], num, offset) 185 | offset += 1 186 | for lex in self.stack: 187 | yield Lexer.lexeme(*lex) 188 | self.stack = [] 189 | self.clear = False 190 | if sys.version_info >= (3, 7): 191 | return 192 | raise StopIteration() 193 | -------------------------------------------------------------------------------- /modiscript/parser.py: -------------------------------------------------------------------------------- 1 | from ast import * 2 | from .utils import LEX, ErrorHandler, ERROR, CONGRESS_RULE 3 | 4 | 5 | class Parser: 6 | def __init__(self, lex): 7 | self.lex = lex 8 | self.length = len(lex) 9 | self._variables = set() 10 | 11 | def parse(self): 12 | """ 13 | Convert to ast 14 | """ 15 | module = self._analyze_module() 16 | fix_missing_locations(module) 17 | return module 18 | 19 | def _debug_details(self, num): 20 | if isinstance(num, dict): 21 | return {'lineno': num['line'], 'col_offset': num['offset']} 22 | return {'lineno': self.lex[num]['line'], 'col_offset': self.lex[num]['offset']} 23 | 24 | def _load_var(self, num): 25 | return Name(id=self.lex[num]['value'], ctx=Load(), **self._debug_details(num)) 26 | 27 | def _store_var(self, num): 28 | return Name(id=self.lex[num]['value'], ctx=Store(), **self._debug_details(num)) 29 | 30 | def _is_not(self, lex): 31 | if isinstance(lex, int): 32 | lex = self.lex[lex] 33 | return lex['lex'] == LEX['var'] and lex['value'] == 'nahi' 34 | 35 | def _analyze(self, num): 36 | """ 37 | Begin a new line. 38 | """ 39 | lexeme = self.lex[num] 40 | if lexeme['lex'] == LEX['if']: 41 | return self._analyze_if(num) 42 | if lexeme['lex'] == LEX['until']: 43 | return self._analyze_until(num) 44 | if lexeme['lex'] == LEX['print']: 45 | return self._analyze_print(num) 46 | if lexeme['lex'] == LEX['input']: 47 | return self._analyze_input(num) 48 | if lexeme['lex'] == LEX['var']: 49 | return self._analyze_assign(num) 50 | return num + 1, None 51 | 52 | def _analyze_module(self): 53 | code = [] 54 | num = 0 55 | while num < self.length: 56 | num, node = self._analyze(num) 57 | if node is not None: 58 | code.append(node) 59 | return Module(body=code, **self._debug_details(0)) 60 | 61 | def _analyze_assign(self, num): 62 | if num + 1 < self.length: 63 | new_num, node = self._analyze_expr(num + 1) 64 | if node is not None: 65 | self._variables.add(self.lex[num]['value']) 66 | return new_num, Assign(targets=[self._store_var(num)], 67 | value=node, **self._debug_details(num)) 68 | return num + 1, None 69 | 70 | def _analyze_input(self, num): 71 | input_func = Call(func=Name(id='input', ctx=Load(), **self._debug_details(num)), 72 | args=[], keywords=[], **self._debug_details(num)) 73 | num += 1 74 | if num < self.length: 75 | lexeme = self.lex[num] 76 | if lexeme['lex'] == LEX['str']: 77 | if lexeme['value'].count(' '): 78 | return num, None 79 | elif lexeme['lex'] != LEX['var']: 80 | return num, None 81 | else: 82 | input_func = Call(func=Name(id='int', ctx=Load(), **self._debug_details(num)), 83 | args=[input_func], keywords=[], **self._debug_details(num)) 84 | self._variables.add(lexeme['value']) 85 | return num + 1, Assign(targets=[self._store_var(num)], 86 | value=input_func, **self._debug_details(num)) 87 | return num, None 88 | 89 | def _analyze_if(self, num): 90 | if num + 1 >= self.length: 91 | return num + 1, None 92 | new_num, cond = self._analyze_expr(num + 1) 93 | if cond is not None and new_num < self.length: 94 | if self.lex[new_num]['lex'] == LEX['then']: 95 | new_num += 1 96 | if new_num < self.length: 97 | if self.lex[new_num]['lex'] == LEX['{']: 98 | new_num, body = self._analyze_block(new_num) 99 | else: 100 | new_num, body = self._analyze(new_num) 101 | if body is not None: 102 | body = [body] 103 | if body is not None: 104 | orelse = None 105 | if self.lex[new_num]['lex'] == LEX['else']: 106 | new_num += 1 107 | if new_num < self.length: 108 | if self.lex[new_num]['lex'] == LEX['{']: 109 | new_num, orelse = self._analyze_block(new_num) 110 | else: 111 | new_num, orelse = self._analyze(new_num) 112 | if orelse is not None: 113 | orelse = [orelse] 114 | if orelse is None: 115 | orelse = [] 116 | return new_num, If(test=cond, body=body, orelse=orelse, **self._debug_details(num)) 117 | raise ErrorHandler(ERROR, "If failed") 118 | 119 | def _analyze_print(self, num): 120 | if num + 1 >= self.length: 121 | return num + 1, None 122 | new_num, node = self._analyze_expr(num + 1) 123 | if node is not None: 124 | return new_num, Expr(value=Call(func=Name(id='print', ctx=Load()), 125 | args=[node], keywords=[]), **self._debug_details(num)) 126 | return num + 1, None 127 | 128 | def _analyze_until(self, num): 129 | if num + 1 >= self.length: 130 | return num + 1, None 131 | new_num, cond = self._analyze_expr(num + 1) 132 | if cond is not None and new_num < self.length: 133 | if self.lex[new_num]['lex'] == LEX['then']: 134 | new_num += 1 135 | if new_num < self.length: 136 | if self.lex[new_num]['lex'] == LEX['{']: 137 | new_num, body = self._analyze_block(new_num) 138 | else: 139 | new_num, body = self._analyze(new_num) 140 | if body is not None: 141 | body = [body] 142 | if body is not None: 143 | return new_num, While(test=UnaryOp(op=Not(), operand=cond, **self._debug_details(num + 1)), 144 | body=body, orelse=[], **self._debug_details(num)) 145 | raise ErrorHandler(ERROR, "Misplaced jab tak") 146 | 147 | def _analyze_block(self, num): 148 | num += 1 149 | code = [] 150 | while num < self.length: 151 | if self.lex[num]['lex'] == LEX['}']: 152 | return num + 1, code 153 | num, node = self._analyze(num) 154 | if node is not None: 155 | code.append(node) 156 | raise ErrorHandler(ERROR, "Missing '}'") 157 | 158 | def _analyze_e(self, num): 159 | lexeme = self.lex[num] 160 | if lexeme['lex'] == LEX['(']: 161 | if num + 1 >= self.length: 162 | return num + 1, None 163 | new_num, code = self._analyze_expr(num + 1) 164 | if self.lex[new_num]['lex'] != LEX[')']: 165 | raise ErrorHandler(ERROR, "Missing ')'") 166 | new_num += 1 167 | if new_num < self.length and self._is_not(new_num): 168 | new_num += 1 169 | if new_num < self.length and self.lex[new_num]['lex'] == LEX['hai']: 170 | new_num += 1 171 | return new_num, code 172 | if lexeme['lex'] == LEX['true']: 173 | k = 2 if (num + 1 < self.length and self.lex[num + 1]['lex'] == LEX['hai']) else 1 174 | return num + k, NameConstant(value=True, **self._debug_details(num)) 175 | if lexeme['lex'] == LEX['false']: 176 | k = 2 if (num + 1 < self.length and self.lex[num + 1]['lex'] == LEX['hai']) else 1 177 | return num + k, NameConstant(value=False, **self._debug_details(num)) 178 | if lexeme['lex'] == LEX['num']: 179 | k = 2 if (num + 1 < self.length and self.lex[num + 1]['lex'] == LEX['hai']) else 1 180 | return num + k, Num(n=int(lexeme['value']), **self._debug_details(num)) 181 | if lexeme['lex'] == LEX['str']: 182 | k = 2 if (num + 1 < self.length and self.lex[num + 1]['lex'] == LEX['hai']) else 1 183 | return num + k, Str(s=lexeme['value'], **self._debug_details(num)) 184 | if lexeme['lex'] == LEX['var']: 185 | if lexeme['value'] in self._variables: 186 | k = 2 if (num + 1 < self.length and self.lex[num + 1]['lex'] == LEX['hai']) else 1 187 | return num + k, Name(id=lexeme['value'], ctx=Load(), **self._debug_details(num)) 188 | if num + 1 >= self.length: 189 | return num + 1, None 190 | return self._analyze_e(num + 1) 191 | raise ErrorHandler(ERROR, 'Unknown symbol') 192 | 193 | def _analyze_d(self, num): 194 | num, prev = self._analyze_e(num) 195 | if prev is None: 196 | raise ErrorHandler(ERROR) 197 | while num < self.length: 198 | lexeme = self.lex[num] 199 | if lexeme['lex'] == LEX['*']: 200 | op = Mult(**self._debug_details(num)) 201 | elif lexeme['lex'] == LEX['/']: 202 | op = Div(**self._debug_details(num)) 203 | elif lexeme['lex'] == LEX['%']: 204 | op = Mod(**self._debug_details(num)) 205 | else: 206 | return num, prev 207 | num += 1 208 | if num >= self.length: 209 | raise ErrorHandler(ERROR, "Missing right operand") 210 | num, node = self._analyze_e(num) 211 | if node is None: 212 | raise ErrorHandler(ERROR) 213 | prev = BinOp(left=prev, op=op, right=node) 214 | return num, prev 215 | 216 | def _analyze_c(self, num): 217 | num, prev = self._analyze_d(num) 218 | if prev is None: 219 | raise ErrorHandler(ERROR) 220 | while num < self.length: 221 | lexeme = self.lex[num] 222 | if lexeme['lex'] == LEX['+']: 223 | op = Add(**self._debug_details(num)) 224 | elif lexeme['lex'] == LEX['-']: 225 | op = Sub(**self._debug_details(num)) 226 | else: 227 | return num, prev 228 | num += 1 229 | if num >= self.length: 230 | raise ErrorHandler(ERROR, "Missing right operand") 231 | num, node = self._analyze_d(num) 232 | if node is None: 233 | raise ErrorHandler(ERROR) 234 | prev = BinOp(left=prev, op=op, right=node) 235 | return num, prev 236 | 237 | def _analyze_b(self, num): 238 | lex_line = self.lex[num]['line'] 239 | op = None 240 | num, prev = self._analyze_c(num) 241 | if prev is None: 242 | raise ErrorHandler(ERROR) 243 | if num >= self.length: 244 | return num, prev 245 | lexeme = self.lex[num] 246 | if lexeme['lex'] in (LEX['<'], LEX['>'], LEX['<='], LEX['>='], LEX['=='], LEX['!=']): 247 | if num + 1 >= self.length: 248 | return num + 1, prev 249 | new_num, node = self._analyze_c(num + 1) 250 | if node is None: 251 | return num + 1, prev 252 | if lexeme['lex'] == LEX['<']: 253 | op = Lt(**self._debug_details(num)) 254 | elif lexeme['lex'] == LEX['>']: 255 | op = Gt(**self._debug_details(num)) 256 | elif lexeme['lex'] == LEX['<=']: 257 | op = LtE(**self._debug_details(num)) 258 | elif lexeme['lex'] == LEX['>=']: 259 | op = GtE(**self._debug_details(num)) 260 | elif lexeme['lex'] == LEX['==']: 261 | op = Eq(**self._debug_details(num)) 262 | elif lexeme['lex'] == LEX['!=']: 263 | op = NotEq(**self._debug_details(num)) 264 | if lexeme['value'] == 'word': 265 | if lexeme['lex'] == LEX['>']: 266 | op = Lt(**self._debug_details(num)) 267 | elif lexeme['lex'] == LEX['<']: 268 | op = Gt(**self._debug_details(num)) 269 | op = Compare(left=prev, ops=[op], comparators=[node], **self._debug_details(num)) 270 | if new_num + 1 < self.length and self.lex[new_num + 1]['lex'] == LEX['var'] and self.lex[new_num + 1][ 271 | 'value'] == 'nahi': 272 | new_num += 1 273 | op = UnaryOp(op=Not(), operand=op, **self._debug_details(new_num)) 274 | if new_num < self.length and self.lex[new_num]['lex'] == LEX['hai']: 275 | new_num += 1 276 | return new_num, op 277 | elif lexeme['lex'] in (LEX['var'], LEX['('], LEX['str'], LEX['num']) and lexeme['line'] == lex_line: 278 | new_num, node = self._analyze_c(num) 279 | if new_num >= self.length: 280 | return new_num, prev 281 | lexeme = self.lex[new_num] 282 | if lexeme['value'] is None: 283 | raise ErrorHandler(ERROR, 'Misplaced relational operator') 284 | if lexeme['lex'] == LEX['<']: 285 | op = Lt(**self._debug_details(new_num)) 286 | elif lexeme['lex'] == LEX['>']: 287 | op = Gt(**self._debug_details(new_num)) 288 | elif lexeme['lex'] == LEX['<=']: 289 | op = LtE(**self._debug_details(new_num)) 290 | elif lexeme['lex'] == LEX['>=']: 291 | op = GtE(**self._debug_details(new_num)) 292 | elif lexeme['lex'] == LEX['==']: 293 | op = Eq(**self._debug_details(new_num)) 294 | elif lexeme['lex'] == LEX['!=']: 295 | op = NotEq(**self._debug_details(new_num)) 296 | op = Compare(left=prev, ops=[op], comparators=[node], **self._debug_details(num)) 297 | if new_num + 1 < self.length and self.lex[new_num + 1]['lex'] == LEX['var'] and self.lex[new_num + 1][ 298 | 'value'] == 'nahi': 299 | new_num += 1 300 | op = UnaryOp(op=Not(), operand=op, **self._debug_details(new_num)) 301 | if new_num + 1 < self.length and self.lex[new_num + 1]['lex'] == LEX['hai']: 302 | new_num += 1 303 | return new_num + 1, op 304 | else: 305 | return num, prev 306 | 307 | def _analyze_a(self, num): 308 | lex_num = num 309 | values = [] 310 | num, node = self._analyze_b(num) 311 | if node is None: 312 | raise ErrorHandler(ERROR) 313 | values.append(node) 314 | while num < self.length: 315 | lexeme = self.lex[num] 316 | if lexeme['lex'] != LEX['&&']: 317 | break 318 | num += 1 319 | if num >= self.length: 320 | raise ErrorHandler(ERROR, 'Unexpected aur') 321 | num, node = self._analyze_b(num) 322 | if node is None: 323 | raise ErrorHandler(ERROR) 324 | values.append(node) 325 | if len(values) == 1: 326 | return num, values.pop() 327 | else: 328 | return num, BoolOp(op=And(**self._debug_details(lex_num)), values=values, **self._debug_details(lex_num)) 329 | 330 | def _analyze_expr(self, num): 331 | """ 332 | expr -> A ya expr | A 333 | A -> B A', A' -> aur B A' | e 334 | B -> C relational C N H | C C relational N H | C 335 | C -> D C', C' -> + D C' | - D C' | e 336 | D -> E D', D' -> * E D' | / E D' | % E D' | e 337 | E -> (expr) H | var H | num H | str H 338 | H -> e | hai 339 | N -> e | nahi 340 | """ 341 | lex_num = num 342 | values = [] 343 | num, node = self._analyze_a(num) 344 | if node is None: 345 | raise ErrorHandler(ERROR) 346 | values.append(node) 347 | while num < self.length: 348 | lexeme = self.lex[num] 349 | if lexeme['lex'] != LEX['||']: 350 | break 351 | num += 1 352 | if num >= self.length: 353 | raise ErrorHandler(ERROR, 'Unexpected aur') 354 | num, node = self._analyze_a(num) 355 | if node is None: 356 | raise ErrorHandler(ERROR) 357 | values.append(node) 358 | if len(values) == 1: 359 | return num, values.pop() 360 | else: 361 | return num, BoolOp(op=Or(**self._debug_details(lex_num)), values=values, **self._debug_details(lex_num)) 362 | -------------------------------------------------------------------------------- /modiscript/utils.py: -------------------------------------------------------------------------------- 1 | PROGRAM = "MODI" 2 | FNF = 404 3 | MISQUOTE = 500 4 | STARTING_TROUBLE = 'Go listen to Modi' 5 | CONGRESS_RULE = 'Acche din nahi aaye' 6 | ERROR = "Oops. Are you sure you're right?" 7 | 8 | LEX = { 9 | '+': 0, 10 | '-': 1, 11 | '*': 2, 12 | '/': 3, 13 | '%': 4, 14 | '==': 10, 15 | '<': 11, 16 | '>': 12, 17 | '<=': 13, 18 | '>=': 14, 19 | '!=': 15, 20 | '!': 20, 21 | '&&': 21, 22 | '||': 22, 23 | '(': 30, 24 | ')': 31, 25 | '{': 32, 26 | '}': 33, 27 | '=': 34, 28 | 'if': 40, 29 | 'then': 41, 30 | 'else': 42, 31 | 'until': 43, 32 | 'print': 44, 33 | 'input': 45, 34 | 'hai': 50, 35 | 'var': 100, 36 | 'num': 101, 37 | 'str': 102, 38 | 'sym': 103, 39 | 'true': 104, 40 | 'false': 105 41 | } 42 | 43 | WORDS = { 44 | "nahin": "nahi", 45 | "tho": "toh", 46 | "bhayyo": "bhaiyo", 47 | "beheno": "behno", 48 | "thak": "tak", 49 | "jyada": "zyada" 50 | } 51 | 52 | 53 | def usage(): 54 | print("Usage:", PROGRAM, "[options]", "filename") 55 | print("-d, --debug\n\toutput lex and parse details to files.") 56 | quit() 57 | 58 | 59 | class ErrorHandler(Exception): 60 | def __init__(self, code, *args): 61 | self.code = code 62 | self.args = args 63 | 64 | def __str__(self): 65 | return ('Error: %s\n:' % self.code) + str(self.args) 66 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { "src": "website/web.py", "use": "@now/python" } 5 | ], 6 | "routes": [ 7 | { "src": "/(.*)", "dest": "website/web.py" } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /website/requirements.txt: -------------------------------------------------------------------------------- 1 | flask-cors 2 | flask 3 | -------------------------------------------------------------------------------- /website/ui/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | -------------------------------------------------------------------------------- /website/ui/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["plugin:vue/essential", "@vue/prettier"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "babel-eslint" 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /website/ui/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /website/ui/README.md: -------------------------------------------------------------------------------- 1 | # modiscript-ui 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /website/ui/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"] 3 | }; 4 | -------------------------------------------------------------------------------- /website/ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "modiscript-ui", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.19.0", 12 | "core-js": "^3.3.2", 13 | "vue": "^2.6.10", 14 | "vuetify": "^2.1.0" 15 | }, 16 | "devDependencies": { 17 | "@vue/cli-plugin-babel": "^4.0.0", 18 | "@vue/cli-plugin-eslint": "^4.0.0", 19 | "@vue/cli-service": "^4.0.0", 20 | "@vue/eslint-config-prettier": "^5.0.0", 21 | "babel-eslint": "^10.0.3", 22 | "eslint": "^5.16.0", 23 | "eslint-plugin-prettier": "^3.1.1", 24 | "eslint-plugin-vue": "^5.0.0", 25 | "prettier": "^1.18.2", 26 | "sass": "^1.19.0", 27 | "sass-loader": "^8.0.0", 28 | "vue-cli-plugin-vuetify": "^2.0.2", 29 | "vue-template-compiler": "^2.6.10", 30 | "vuetify-loader": "^1.3.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /website/ui/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /website/ui/public/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-144x144.png -------------------------------------------------------------------------------- /website/ui/public/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-192x192.png -------------------------------------------------------------------------------- /website/ui/public/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-36x36.png -------------------------------------------------------------------------------- /website/ui/public/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-48x48.png -------------------------------------------------------------------------------- /website/ui/public/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-72x72.png -------------------------------------------------------------------------------- /website/ui/public/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/android-icon-96x96.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-114x114.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-120x120.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-144x144.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-152x152.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-180x180.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-57x57.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-60x60.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-72x72.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-76x76.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon-precomposed.png -------------------------------------------------------------------------------- /website/ui/public/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/apple-icon.png -------------------------------------------------------------------------------- /website/ui/public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/favicon-16x16.png -------------------------------------------------------------------------------- /website/ui/public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/favicon-32x32.png -------------------------------------------------------------------------------- /website/ui/public/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/favicon-96x96.png -------------------------------------------------------------------------------- /website/ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/favicon.ico -------------------------------------------------------------------------------- /website/ui/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ModiScript - The Programming Language for India's Growing Population! 23 | 24 | 25 | 26 | 27 | 28 | 29 | We're sorry but modiscript-ui doesn't work properly without JavaScript enabled. Please enable it to continue. 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /website/ui/public/ms-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/ms-icon-144x144.png -------------------------------------------------------------------------------- /website/ui/public/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/ms-icon-150x150.png -------------------------------------------------------------------------------- /website/ui/public/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/ms-icon-310x310.png -------------------------------------------------------------------------------- /website/ui/public/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/public/ms-icon-70x70.png -------------------------------------------------------------------------------- /website/ui/src/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | ModiScript 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 40 | -------------------------------------------------------------------------------- /website/ui/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VPanjeta/ModiScript/c67cb9af238e485826ca5b186c4cce3ed7d8edf0/website/ui/src/assets/logo.png -------------------------------------------------------------------------------- /website/ui/src/codes.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "hello-world": `Mitrooon 3 | bhaiyo aur behno "Hello World" 4 | Achhe din aa gaye`, 5 | "if-else": `Mitrooon 6 | agar baat sach hai 7 | bhaiyo aur behno "Modi sabse achhe pradhan mantri hai." 8 | nahi toh 9 | bhaiyo aur behno "Rahul Gandhi ko PM banaiye" 10 | Achhe din aa gaye 11 | `, 12 | mandir: `mitrooon 13 | UP "BJP governed state hai" 14 | SP "opposition me hai" 15 | agar ye sach hai 16 | bhaiyo aur behno "Mandir wahin banayenge" 17 | nahi toh 18 | bhaiyo aur behno "Mandir to wahin banega" 19 | achhe din aa gaye`, 20 | scam: `mitrooon 21 | itne 1 hai 22 | jab tak itne 100 se zyada{ 23 | bhaiyo aur behno "Congress ne " hai 24 | bhaiyo aur behno itne hai 25 | bhaiyo aur behno "crore ka scam kiya" 26 | itne (itne+1) hai 27 | } 28 | achhe din aa gaye 29 | `, 30 | factorial: ` 31 | mitroon 32 | factorial 1 hai 33 | i 1 hai 34 | bhaiyo aur behno "ek nambar do" 35 | mann ki baat nambar 36 | agar nambar 0 se kam hai 37 | bhaiyo aur behno "nakaratmak sankhyao ka factorial nai hota bhaiyo aur behno par mujhe sirf 50 din dijiye" 38 | nahi toh { 39 | jab tak i nambar se zyada hai { 40 | factorial factorial taimes i hai 41 | i i plus 1 hai 42 | } 43 | } 44 | 45 | bhaiyo aur behno nambar 46 | bhaiyo aur behno "ka factorial" 47 | bhaiyo aur behno factorial 48 | bhaiyo aur behno "hai" 49 | acche din aa gaye 50 | `, 51 | custom: "" 52 | }; 53 | -------------------------------------------------------------------------------- /website/ui/src/components/home.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ModiScript 5 | 6 | 7 | For the Next Billion Indians! 8 | 9 | 10 | 11 | 12 | 21 | 22 | 23 | 29 | 30 | 31 | 37 | 38 | 39 | Submit 40 | 41 | 47 | 48 | 49 | 50 | 51 | Created By The 52 | 53 | ModiScript Team 54 | . 55 | 56 | 57 | 58 | 59 | 101 | -------------------------------------------------------------------------------- /website/ui/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import vuetify from "./plugins/vuetify"; 4 | 5 | Vue.config.productionTip = false; 6 | 7 | new Vue({ 8 | vuetify, 9 | render: h => h(App) 10 | }).$mount("#app"); 11 | -------------------------------------------------------------------------------- /website/ui/src/plugins/vuetify.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Vuetify from "vuetify/lib"; 3 | 4 | Vue.use(Vuetify); 5 | 6 | export default new Vuetify({}); 7 | -------------------------------------------------------------------------------- /website/ui/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | lintOnSave: false, 3 | transpileDependencies: ["vuetify"] 4 | }; 5 | -------------------------------------------------------------------------------- /website/web.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("..") 3 | from io import StringIO 4 | from modiscript.utils import ErrorHandler 5 | from modiscript.api import ModiScript 6 | from flask_cors import CORS 7 | from flask import Flask, request, jsonify 8 | 9 | app = Flask(__name__) 10 | CORS(app, resources={r"/*": {"origins": "*"}}) 11 | 12 | ms = ModiScript() 13 | orignal_stdout = sys.stdout 14 | orignal_stdin = sys.stdin 15 | 16 | 17 | def captureOutput(func): 18 | def inner(*args, **kwargs): 19 | sys.stdout = StringIO() 20 | 21 | func(*args, **kwargs) 22 | 23 | out = sys.stdout.getvalue() 24 | sys.stdout = orignal_stdout 25 | return out 26 | return inner 27 | 28 | 29 | @captureOutput 30 | def execute(code, stdin=None): 31 | if stdin: 32 | sys.stdin = StringIO(str(stdin)) 33 | ms.execute(code, "code") 34 | sys.stdin = orignal_stdin 35 | 36 | 37 | @app.route("/", methods=["POST"]) 38 | def run(): 39 | body = request.get_json(silent=True) 40 | code = body.get("code") 41 | stdin = body.get("stdin") 42 | if not code: 43 | return jsonify({"error": "Executable code has not been provided."}), 400 44 | 45 | try: 46 | return jsonify({"out": execute(code, stdin)}), 200 47 | except ErrorHandler as e: 48 | return jsonify({"error": str(e)}), 402 49 | --------------------------------------------------------------------------------
7 | For the Next Billion Indians! 8 |
51 | Created By The 52 | 53 | ModiScript Team 54 | . 55 |