{"id":21270193,"url":"https://github.com/raghav714/rdds-online-compiler","last_synced_at":"2025-03-15T11:45:41.134Z","repository":{"id":226796325,"uuid":"156080104","full_name":"Raghav714/RDDS-online-compiler","owner":"Raghav714","description":"Compiler","archived":false,"fork":false,"pushed_at":"2019-03-05T12:13:26.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-22T02:27:13.557Z","etag":null,"topics":["cloud-computing","compiler","compiler-construction","compiler-design","grammar","language-processing","online-compiler","parse","parser-combinators","programing-language","scanner"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Raghav714.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-11-04T12:32:11.000Z","updated_at":"2023-01-20T03:53:59.000Z","dependencies_parsed_at":"2024-03-09T18:54:22.605Z","dependency_job_id":null,"html_url":"https://github.com/Raghav714/RDDS-online-compiler","commit_stats":null,"previous_names":["raghav714/rdds-online-compiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2FRDDS-online-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2FRDDS-online-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2FRDDS-online-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2FRDDS-online-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Raghav714","download_url":"https://codeload.github.com/Raghav714/RDDS-online-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725558,"owners_count":20337667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-computing","compiler","compiler-construction","compiler-design","grammar","language-processing","online-compiler","parse","parser-combinators","programing-language","scanner"],"created_at":"2024-11-21T08:16:04.205Z","updated_at":"2025-03-15T11:45:41.112Z","avatar_url":"https://github.com/Raghav714.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RDDS-online-compiler\nThe compiler is build from scratch with module :-\u003c/br\u003e\n• Lexical analyser\u003c/br\u003e\n• Parser\u003c/br\u003e\n• Intermediate Code Generator\u003c/br\u003e\n• Error handling\u003c/br\u003e\n• Symbol table\u003c/br\u003e\n## LEXICAL ANALYSER AND SCANNER\n• First program is run on the source file and then the code is broken into the list of distinct lines.\u003c/br\u003e\n• at the start of each non-whitespace character, the frst character is used to determine the type of the\ntoken to expect.\u003c/br\u003e\n• The token is returned if the type is matched without any issue Otherwise, a scanner warning is thrown.\u003c/br\u003e\n• The scanner warnings are never fatal, though syntactically the tokens returned may cause a parser error.\u003c/br\u003e\n• For instance, if a string literal has no end quote a warning will be thrown and a quote will be assumed at the end of the line.\u003c/br\u003e\n## PARSER\n• The left recursive from the grammar is removed.\u003c/br\u003e\n• Type-checking is performed in expressions by returning the types from the expression tree functions and evaluating types for compatibility if an operation is performed.\u003c/br\u003e\n• Parser resync points are used throughout the compiler to continue parsing if an error is encountered without propagating spurious error messages.\u003c/br\u003e\n• Note that once a fatal error or any kind is encountered, code will no longer be generated.\u003c/br\u003e\n## INTERMEDIATE CODE GENERATOR\n• Memory and registers for the operation of the program are defned and used as 32-bit integer arrays.\u003c/br\u003e\n• All non-integer types present in the program are cast as integers for storage in the memory spaces.\u003c/br\u003e\n• To ensure that pointers are 32-bit and may be cast to integer without issue, the `gcc` compiler fag `-m32` is used.\u003c/br\u003e\n• Future improvements could be made to \"push back\" register allocation to the frst register (`R[0]`) at the end of each scope.\u003c/br\u003e\n## LANGUAGE SYNTAXPROGRAM BODY\nthe program \\\u003cname\\\u003e is\u003c/br\u003e\ndefine \\\u003cdeclaration\\\u003e\u003c/br\u003e\nbody\u003c/br\u003e\n\\\u003cstatement\\\u003e\u003c/br\u003e\nfnish program\u003c/br\u003e\n## FUNCTION DEFINITION\nfunction \\\u003cfunction name\\\u003e(\\\u003cdatatype\\\u003e \\\u003cvariable\\\u003e in, \\\u003cdatatype\\\u003e \\\u003cvariable\\\u003e out) is\u003c/br\u003e\n\\\u003cdeclaration\\\u003e\u003c/br\u003e\nbody\u003c/br\u003e\n\\\u003cstatement\\\u003efinsh functione;\u003c/br\u003e\n## IF ELSE STATEMENT\nif (\\\u003ccondition\\\u003e) then\u003c/br\u003e\n\\\u003cstatement\\\u003e\u003c/br\u003e\nelse\u003c/br\u003e\n\\\u003cstatement\\\u003e\u003c/br\u003e\nfinsh if\u003c/br\u003e\n## LOOP\nfor (counter = counter + 1e counter \\\u003c= num_loops)\u003c\\br\u003e\n\\\u003cstatement\\\u003e\u003c\\br\u003e\nfnish for\u003c\\br\u003e\n## FUNCTION CALL\n\\\u003cfunction name\\\u003e(\\\u003cparameter to pass\\\u003e,\\\u003creturn value\\\u003e)\n## DATA TYPE\n• int – Integer\u003c/br\u003e\n• bool – Boolean\u003c/br\u003e\n• str – String\u003c/br\u003e\n• foat – Float\u003c/br\u003e\n## FUNCTION\n• putstr(\"Enter 1st Integer:\")\u003c/br\u003e\n• getint(variable)\u003c/br\u003e\n• putint(result)\u003c/br\u003e\n• getstr(“enter string”)\u003c/br\u003e\n• getbool(testbool)\u003c/br\u003e\n• putbool(testbool)\u003c/br\u003e\n• getfoat(testfoat)\u003c/br\u003e\n• putfoat(testfoat)\u003c/br\u003e\n## GRAMMAR\n\\\u003cprogram\\\u003e ::= \\\u003cprogram_header\\\u003e \\\u003cprogram_body\\\u003e\u003c/br\u003e\n\\\u003cprogram_header\\\u003e ::= ‘ the’ 'program' \\\u003cidentifier\\\u003e 'is'\u003c/br\u003e\n\\\u003cprogram_body\\\u003e ::= ‘ define’( \\\u003cdeclaration\\\u003e ';' )* 'body' ( \\\u003cstatement\\\u003e ';' )* 'finish' 'program' \u003c/br\u003e\n\\\u003cdeclaration\\\u003e ::= [ 'global' ] \\\u003cprocedure_declaration\\\u003e [ 'global' ] \\\u003cvariable_declaration\\\u003e\u003c/br\u003e\n\\\u003cvariable_declaration\\\u003e ::=\\\u003ctype_mark\\\u003e \\\u003cidentifier\\\u003e [ '[' \\\u003carray_size\\\u003e ']' ] \u003c/br\u003e\n\\\u003ctype_mark\\\u003e ::= 'int’' | 'float' | 'bool' | 'str' \u003c/br\u003e\n\\\u003cprocedure_declaration\\\u003e ::= \\\u003cprocedure_header\\\u003e \\\u003cprocedure_body\\\u003e \u003c/br\u003e\n\\\u003cprocedure_header\\\u003e ::='function' \\\u003cidentifier\\\u003e '(' [ \\\u003cparameter_list\\\u003e ] ')' ’is’\u003c/br\u003e\n\\\u003cprocedure_body\\\u003e ::= ( \\\u003cdeclaration\\\u003e ';' )* ‘ body' ( \\\u003cstatement ';' )* 'finish’ 'function' \u003c/br\u003e\n\\\u003cparameter_list\\\u003e ::= \\\u003cparameter\\\u003e ',' \\\u003cparameter_list\\\u003e |\\\u003cparameter\\\u003e \u003c/br\u003e\n\\\u003cparameter\\\u003e ::= \\\u003cvariable_declaration\\\u003e ( 'in' | 'out' )\u003c/br\u003e\n\\\u003cstatement\\\u003e ::= \\\u003cassignment_statement\\\u003e | \\\u003cif_statement\\\u003e | \\\u003cloop_statement\\\u003e | \\\u003creturn_statement\\\u003e |\n\\\u003cprocedure_call\\\u003e \u003c/br\u003e\n\\\u003cassignment_statement\\\u003e ::= \\\u003cdestination\\\u003e '=' \\\u003cexpression\\\u003e\u003c/br\u003e\n\\\u003cif_statement\\\u003e ::= 'if' '(' \\\u003cexpression\\\u003e ')' 'then' ( \\\u003cstatement\\\u003e ';' )+ [ 'else' ( \\\u003cstatement\\\u003e ';' )+ ]\n'finish' 'if'\u003c/br\u003e\n\\\u003cloop_statement\\\u003e ::= 'for' '(' \\\u003cassignment_statement\\\u003e ';' \\\u003cexpression\\\u003e ')' ( \\\u003cstatement\\\u003e ';' )* 'finish' 'for' \u003c/br\u003e\n\\\u003cprocedure_call\\\u003e ::= \\\u003cidentifier\\\u003e '(' [ \\\u003cargument_list\\\u003e ] ')'\u003c/br\u003e\n\\\u003cargument_list\\\u003e ::= \\\u003cexpression\\\u003e ',' \\\u003cargument_list\\\u003e |\\\u003cexpression\\\u003e \u003c/br\u003e\n\\\u003cdestination\\\u003e ::= \\\u003cidentifier\\\u003e [ '[' \\\u003cexpression\\\u003e ']' ] \u003c/br\u003e\n\\\u003cexpression\\\u003e ::= \\\u003cexpression\\\u003e '\u0026' \\\u003carith_op\\\u003e | \\\u003cexpression\\\u003e '|' \\\u003carith_op\\\u003e | [ 'not' ] \\\u003carith_op\\\u003e \u003c/br\u003e\n\\\u003carith_op\\\u003e ::= \\\u003carith_op\\\u003e '+' \\\u003crelation\\\u003e | \\\u003carith_op\\\u003e '-' \\\u003crelation\\\u003e |\\\u003crelation\\\u003e \u003c/br\u003e\n\\\u003crelation\\\u003e ::= \\\u003crelation\\\u003e '\\\u003c' \\\u003cterm\\\u003e | \\\u003crelation\\\u003e '\\\u003e' \\\u003cterm\\\u003e | \\\u003crelation\\\u003e '\\\u003e=' \\\u003cterm\\\u003e | \\\u003crelation\\\u003e '\\\u003c=' \\\u003cterm\\\u003e |\\\u003crelation\\\u003e '==' \\\u003cterm\\\u003e |\\\u003crelation\\\u003e '!=' \\\u003cterm\\\u003e |\\\u003cterm\\\u003e \u003c/br\u003e\n\\\u003cterm\\\u003e ::= \\\u003cterm\\\u003e '*' \\\u003cfactor\\\u003e | \\\u003cterm\\\u003e '/' \\\u003cfactor\\\u003e | \\\u003cfactor\\\u003e \u003c/br\u003e\n\\\u003cfactor\\\u003e ::= '(' \\\u003cexpression\\\u003e ')' | [ '-' ] \\\u003cname\\\u003e | [ '-' ] \\\u003cnumber\\\u003e | \\\u003cstring\\\u003e | 'true' | 'false' |\u003c/br\u003e\n\\\u003cname\\\u003e ::= \\\u003cidentifier\\\u003e [ '[' \\\u003cexpression\\\u003e ']' ]\u003c/br\u003e\n\\\u003cidentifier\\\u003e ::= [a-zA-Z][a-zA-Z0-9_]* \u003c/br\u003e\n\\\u003cnumber\\\u003e ::= [0-9][0-9_]*[.[0-9_]*]? \u003c/br\u003e\n\\\u003cstring\\\u003e ::= \"[a-zA-Z0-9 _,;:.']*\" \u003c/br\u003e\n## GUI \n![compiler1](https://user-images.githubusercontent.com/29707542/49634701-85c6d580-fa23-11e8-852b-89079215d67c.png)\n![compiler2](https://user-images.githubusercontent.com/29707542/49634708-8b242000-fa23-11e8-9363-0aef06a62514.png)\n\n### STEPS to run the program\n$ `sudo apt update`\u003c/br\u003e\n$ `sudo apt install apache2`\u003c/br\u003e\n$ `sudo apt-get install python3`\u003c\\br\u003e\n$ `sudo systemctl stop apache2.service` \u003c/br\u003e\n$ `sudo systemctl start apache2.service` \u003c/br\u003e\n$ `sudo systemctl enable apache2.service` \u003c/br\u003e\n$ `sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-zip php7.2-curl`\u003c/br\u003e\nCopy the HTML, PHP, CSS, input.txt and test.src file in /var/www/html/ and type the localhost/index1.php in browser.\u003c/br\u003e\nEdit the Path of the file `compiler.py` in index1.php \u003c/br\u003e\nif the program doesnot work then run $ `sudo chmod 777 *` in /var/www/html/ \u003c/br\u003e\nif you wish to make RDDS as a command then open the bashrc file(sudo gedit ~/.bashrc) and write the command `alias RDDS ='python3 /home/raghav/Downloads/compiler/2compiler/compiler.py -o OUT'` in this you need to replace the path of compiler.py file.\u003c/br\u003e\nuse the command `RDDS rdds_test/simple_add.src` and `./a.out` to see the output\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghav714%2Frdds-online-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraghav714%2Frdds-online-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghav714%2Frdds-online-compiler/lists"}