{"id":21270186,"url":"https://github.com/raghav714/compiler-programs","last_synced_at":"2026-05-03T05:32:52.916Z","repository":{"id":226796343,"uuid":"150743086","full_name":"Raghav714/compiler-programs","owner":"Raghav714","description":"compiler code ","archived":false,"fork":false,"pushed_at":"2019-03-05T12:12:37.000Z","size":45,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-31T10:39:46.399Z","etag":null,"topics":["calculator","compiler","first","follow","lex","lexical-analysis","ll1","python","yacc"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"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-09-28T13:15:35.000Z","updated_at":"2019-09-11T16:45:07.000Z","dependencies_parsed_at":"2024-03-09T18:54:22.824Z","dependency_job_id":null,"html_url":"https://github.com/Raghav714/compiler-programs","commit_stats":null,"previous_names":["raghav714/compiler-programs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Raghav714/compiler-programs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2Fcompiler-programs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2Fcompiler-programs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2Fcompiler-programs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2Fcompiler-programs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Raghav714","download_url":"https://codeload.github.com/Raghav714/compiler-programs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raghav714%2Fcompiler-programs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32559715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T03:21:47.309Z","status":"ssl_error","status_checked_at":"2026-05-03T03:21:43.884Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["calculator","compiler","first","follow","lex","lexical-analysis","ll1","python","yacc"],"created_at":"2024-11-21T08:16:00.198Z","updated_at":"2026-05-03T05:32:52.902Z","avatar_url":"https://github.com/Raghav714.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Left Recursion ##\nThe left recursion from a grammar is removed in the *left_recursion.py*\nto run the program :- $python left_recursion.py\u003cbr /\u003e \nlength3\u003cbr /\u003e\nkeyE\u003cbr /\u003e\nnumber of production2\u003cbr /\u003e\nE+F\u003cbr /\u003e\nF\u003cbr /\u003e\nkeyF\u003cbr /\u003e\nnumber of production2\u003cbr /\u003e\nF*G\u003cbr /\u003e\nG\u003cbr /\u003e\nkeyG\u003cbr /\u003e\nnumber of production2\u003cbr /\u003e\n(G)\u003cbr /\u003e\ni\u003cbr /\u003e\n{'E': ['E+F', 'F'], 'G': ['(G)', 'i'], 'F': ['F*G', 'G']}\u003cbr /\u003e\nleft recursion found\u003cbr /\u003e\nleft recursion found\u003cbr /\u003e\n{\"E'\": ['', \"+FE'\"], \"F'\": ['', \"*GF'\"], 'E': \"FE'\", 'G': ['(G)', 'i'], 'F': \"GF'\"}\u003cbr /\u003e\nThe obtained output is left recursion free.\n## Left Factoring ##\nThe left factoring is removed in *left_fact.py*\u003cbr /\u003e\nto run the program :- $python left_fact.py \u003cbr /\u003e\nlength01\u003cbr /\u003e\nkeyE\u003cbr /\u003e\nnumber of production4\u003cbr /\u003e\nabAB\u003cbr /\u003e\nabCD\u003cbr /\u003e\nabEF\u003cbr /\u003e\nab\u003cbr /\u003e\nthe given grammar grammar\u003cbr /\u003e\n{'E': ['abAB', 'abCD', 'abEF', 'ab']}\u003cbr /\u003e\nremoving left factoring free grammer\u003cbr /\u003e\n{\"E'\": ['ab'], 'E': ['AB', 'CD', 'EF', '']}\u003cbr /\u003e\nThe obtained grammar is left factoring free.\n## Lexical Analyser ##\nlexical analyser is bulid using using PLY python programing language and lex tool.\u003cbr /\u003e\nlexical_lex.py contain python implemented code of lex, it will list out all the token present in sum.c\u003cbr /\u003e\nto run the program :- $python lexical_lex.py \u003cbr /\u003e\nLexToken(INCLUDE,'#include',1,0)\u003cbr /\u003e\nLexToken(LESSER,'\u003c',1,8)\u003cbr /\u003e\nLexToken(ID,'stdio',1,9)\u003cbr /\u003e\nIllegal character '.'\u003cbr /\u003e\nLexToken(ID,'h',1,15)\u003cbr /\u003e\nLexToken(GREATER,'\u003e',1,16)\u003cbr /\u003e\nLexToken(VOID,'void',2,18)\u003cbr /\u003e\nLexToken(FUNCTION,'main(',2,23)\u003cbr /\u003e\nLexToken(RPAREN,')',2,28)\u003cbr /\u003e\nLexToken(LBRAC,'{',3,30)\u003cbr /\u003e\nLexToken(INT,'int',5,43)\u003cbr /\u003e\nLexToken(ID,'a',5,47)\u003cbr /\u003e\nLexToken(COMMA,',',5,48)\u003cbr /\u003e\nLexToken(ID,'b',5,49)\u003cbr /\u003e\nLexToken(COLON,';',5,50)\u003cbr /\u003e\nLexToken(PRINTF,'printf(',6,52)\u003cbr /\u003e\nLexToken(RPAREN,')',6,77)\u003cbr /\u003e\nLexToken(COLON,';',6,78)\u003cbr /\u003e\nLexToken(SCANF,'scanf(',7,80)\u003cbr /\u003e\nLexToken(COMMA,',',7,92)\u003cbr /\u003e\nIllegal character '\u0026'\u003cbr /\u003e\nLexToken(ID,'a',7,94)\u003cbr /\u003e\nLexToken(COMMA,',',7,95)\u003cbr /\u003e\u003cbr /\u003e\nIllegal character '\u0026'\u003cbr /\u003e\nLexToken(ID,'b',7,97)\u003cbr /\u003e\nLexToken(RPAREN,')',7,98)\u003cbr /\u003e\nLexToken(COLON,';',7,99)\u003cbr /\u003e\nLexToken(INT,'int',8,101)\u003cbr /\u003e\nLexToken(ID,'s',8,105)\u003cbr /\u003e\nLexToken(EQUAL,'=',8,107)\u003cbr /\u003e\nLexToken(ID,'a',8,109)\u003cbr /\u003e\nLexToken(PLUS,'+',8,110)\u003cbr /\u003e\nLexToken(ID,'b',8,111)\u003cbr /\u003e\nLexToken(COLON,';',8,112)\u003cbr /\u003e\nLexToken(PRINTF,'printf(',9,114)\u003cbr /\u003e\nLexToken(COMMA,',',9,132)\u003cbr /\u003e\nLexToken(ID,'s',9,133)\u003cbr /\u003e\nLexToken(RPAREN,')',9,134)\u003cbr /\u003e\nLexToken(COLON,';',9,135)\u003cbr /\u003e\nLexToken(RBRAC,'}',10,137)\u003cbr /\u003e\n## First, Follow and LL1  table ##\nThe program first.py will calculate first the program will automatically remove all left factoring and left recursion in the grammar.\nthe ll1table.py contain first, follow and ll1 table in the code.\nthe code is broken down into the different different function.\n## Calculator design using lex and yacc ##\nA basic calculator is designed using the grammar.\nthe calculator perform addition, subtraction, multiplication , divison and negation of the numbers in the equation\ncal_lex.l is the lex code lexically analyse the grammar\ncal_yac.y is the yacc code to sematically analyse the grammar\ncommand to run the code:-\n$lex cal_lex.l\u003cbr /\u003e\n$yacc cal_yac.y\u003cbr /\u003e\n$gcc y.tab.c -ly -lfl -lm\u003cbr /\u003e\n$./a.out\u003cbr /\u003e\nEnter the expression: 2+3+4\nAnswer: 9 \nEnter:\n\n## Other program ##\nassignement.l is the lex code written to perform five task:-\n1. count the word start with vowel along with position of word.\n2. count the word start with consonats along with position of word.\n3. count the article along with position.\n4. count the numbers along with position.\n5. count number of line in file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghav714%2Fcompiler-programs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraghav714%2Fcompiler-programs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraghav714%2Fcompiler-programs/lists"}