{"id":21029456,"url":"https://github.com/rex706/pl0-compiler","last_synced_at":"2026-04-11T16:03:11.053Z","repository":{"id":73195766,"uuid":"89180130","full_name":"rex706/PL0-Compiler","owner":"rex706","description":"Compiler for the PL0 language written in C.","archived":false,"fork":false,"pushed_at":"2017-04-24T19:45:32.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T15:17:19.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rex706.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2017-04-23T23:50:34.000Z","updated_at":"2017-04-23T23:50:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"a006b89e-9df5-43e8-bbd1-ddfd10f34c5b","html_url":"https://github.com/rex706/PL0-Compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rex706%2FPL0-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rex706%2FPL0-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rex706%2FPL0-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rex706%2FPL0-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rex706","download_url":"https://codeload.github.com/rex706/PL0-Compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243466985,"owners_count":20295309,"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":[],"created_at":"2024-11-19T12:12:47.224Z","updated_at":"2025-12-29T16:50:35.070Z","avatar_url":"https://github.com/rex706.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PL/0 Compiler\n\nCompiler for the PL/0 language with registers written in C.\n\n*Error recovery not implemented.*\n\n------------------------\n\nCompiler will first take in any text file from the command line of any name,\nthen take in any amount of the available commands in any order separated by spaces,\nand will optionally output to a text file of any name. \n\n\n**Compiling in Linux Environment:**\n\ngcc -o [name] PL0Compiler.c LexiAnalyze.c ParserCodeGen.c PL0VM.c\n\n\n**Running in Linux Environment:**\n\n./[name] [input] [commands] \u003e [output]\n\n\n**Print commands:**\n\n-s - print input source code.\n\n-l - print list of lexemes.\n\n-t - print lexemes in table format.\n\n-a - print generated assembly code.\n\n-o - print generated code in op format.\n\n-v - print virtual machine execution trace and registers.\n\n\n**Compile and command examples:**\n\nPrint multiple types of output to the console:\n\n./compile input.txt –l –a –v -s\t\t\n\nPrint only the VM execution trace and registers to the console:\n\n./compile input.txt –v\n\nPrint nothing to the console except for \"in\" and \"out\":\t\n\n./compile input.txt\t\t\t\t\t\n\nDivert all printing to output.txt:\n\n./compile input.txt \u003e output.txt\t\n\n\"/Cases\" directory contains various test cases and examples that can be used with the compiler.\n\n------------------------\n\n**EBNF of PL/0:**\n\n\nprogram :: = block \".\" .\n\nblock :: = const-declaration var-declaration procedure-declaration statement.\n\nconst-declaration :: = [\"const\" ident \"=\" number{ \",\" ident \"=\" number } \";\"].\n\nvar-declaration :: = [\"var \"ident{ \",\" ident } \";\"].\n\nprocedure-declaration :: = { \"procedure\" ident \";\" block \";\" }\n\nstatement :: = [ident \":=\" expression\n\n\t\t\t| \"call\" ident\n\t\t\t\t\n\t\t\t| \"begin\" statement{ \";\" statement } \"end\"\n\t\t\t\t\n\t\t\t| \"if\" condition \"then\" statement[\"else\" statement]\n\t\t\t\t\n\t\t\t| \"while\" condition \"do\" statement\n\t\t\t\t\n\t\t\t| \"read\" ident\n\t\t\t\t\n\t\t\t| \"write\" expression\n\t\t\t\t\n\t\t\t| e] .\n\t\t\t\t\ncondition :: = \"odd\" expression\n\n\t\t\t| expression  rel-op  expression.\n\t\t\t\t\nrel-op :: = \"=\" | \"\u003c\u003e\" | \"\u003c\" | \"\u003c=\" | \"\u003e\" | \"\u003e=\".\n\nexpression :: = [\"+\" | \"-\"] term{ (\"+\" | \"-\") term }.\n\nterm :: = factor{ (\"*\" | \"/\") factor }.\n\nfactor :: = ident | number | \"(\" expression \")\".\n\nnumber :: = digit{ digit }.\n\nident :: = letter{ letter | digit }.\n\ndigit :: = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\".\n\nletter :: = \"a\" | \"b\" | … | \"y\" | \"z\" | \"A\" | \"B\" | ... | \"Y\" | \"Z\".\n\n\n**Wirth’s rules for EBNF:**\n\n[] means an optional item.\n\n{ } means repeat 0 or more times.\n\nTerminal symbols are enclosed in quote marks.\n\nA period is used to indicate the end of the definition of a syntactic class.\n\n\n------------------------\n\n**Lexical Conventions for PL/0:**\n\n\nA numerical value is assigned to each token (internal representation) as follows: \n\nnulsym = 1, identsym = 2, numbersym = 3, plussym = 4, minussym = 5, multsym = 6,  \n\nslashsym = 7, oddsym = 8,  eqlsym = 9, neqsym = 10, lessym = 11, leqsym = 12, \n\ngtrsym = 13, geqsym = 14, lparentsym = 15, rparentsym = 16, commasym = 17, semicolonsym = 18, \n\nperiodsym = 19, becomessym = 20, beginsym = 21, endsym = 22, ifsym = 23, thensym = 24, \n\nwhilesym = 25, dosym = 26, callsym = 27, constsym = 28, varsym = 29, procsym = 30, \n\nwritesym = 31, readsym = 32, elsesym = 33.\n\n\nReserved Words: const, var, procedure, call, begin, end, if, then, else, while, do, read, write.\n\nSpecial Symbols: '+', '-', '*', '/', '(', ')', '=', ',', '.', '\u003c', '\u003e', ';', ':'.\n\nIdentifiers: identsym = letter (letter | digit)* \n\nNumbers: numbersym = (digit)+\n\nInvisible Characters: tab, white spaces, newline\n\nComments denoted by: /* . . . */\n\n\n------------------------\n\n*Error messages for the tiny PL/0 Parser:**\n\n1.\tUse = instead of :=.\n2.\t= must be followed by a number.\n3.\tIdentifier must be followed by =.\n4.\tconst, var, procedure must be followed by identifier.\n5.\tSemicolon or comma missing.\n6.\tIncorrect symbol after procedure declaration.\n7.\tStatement expected.\n8.\tIncorrect symbol after statement part in block.\n9.\tPeriod expected.\n10.\tSemicolon between statements missing.\n11.\tUndeclared identifier.\n12.\tAssignment to constant or procedure is not allowed.\n13.\tAssignment operator expected.\n14.\tcall must be followed by an identifier.\n15.\tCall of a constant or variable is meaningless.\n16.\tthen expected.\n17.\tSemicolon or } expected.\n18.\tdo expected.\n19.\tIncorrect symbol following statement.\n20.\tRelational operator expected.\n21.\tExpression must not contain a procedure identifier.\n22.\tRight parenthesis missing.\n23.\tThe preceding factor cannot begin with this symbol.\n24.\tAn expression cannot begin with this symbol.\n25.\tThis number is too large.\n26.\tIdentifier must follow read.\n27.\tIdentifier must follow write.\n28.\tProcedures not yet supported.\n29.\tInvalid character detected.\n30.\tUse of an unassigned variable.\n31.\tReserved keyword cannot be used as an identifier name.\n32.\tAll registers already in use.\n33.\tIdentifier name is too long.\n34.\tEnd comment was never opened.\n35.\tComment never closed.\n\n------------------------\n\nAuthor:\nAlec Psinakis","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frex706%2Fpl0-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frex706%2Fpl0-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frex706%2Fpl0-compiler/lists"}