{"id":15324448,"url":"https://github.com/spaghettifunk/ayec-compiler","last_synced_at":"2026-06-19T02:32:20.469Z","repository":{"id":29505188,"uuid":"33043313","full_name":"spaghettifunk/AyeC-Compiler","owner":"spaghettifunk","description":"Compiler Project at Uppsala University","archived":false,"fork":false,"pushed_at":"2015-03-28T17:50:53.000Z","size":164,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T18:44:46.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/spaghettifunk.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}},"created_at":"2015-03-28T17:39:24.000Z","updated_at":"2017-12-09T13:00:36.000Z","dependencies_parsed_at":"2022-09-09T19:01:50.711Z","dependency_job_id":null,"html_url":"https://github.com/spaghettifunk/AyeC-Compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spaghettifunk/AyeC-Compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghettifunk%2FAyeC-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghettifunk%2FAyeC-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghettifunk%2FAyeC-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghettifunk%2FAyeC-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spaghettifunk","download_url":"https://codeload.github.com/spaghettifunk/AyeC-Compiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spaghettifunk%2FAyeC-Compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34515405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-01T09:26:51.573Z","updated_at":"2026-06-19T02:32:20.446Z","avatar_url":"https://github.com/spaghettifunk.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AyeC-Compiler\nCompiler Project at Uppsala University\n\nThis project has been made by Anton Weber and Davide Berdin to fulfil the course of Compiler Project.\nAyeC compiler will understand a subset of the C language called uC Language.\n\n- The Parser uses JavaCC (https://javacc.java.net)\n- The rest of the code has been written in Java \n\nCredits for the page goes to Alexandra Jimborean\n\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\"\u003e\u003chead\u003e\n\u003ctitle\u003eThe uC language\u003c/title\u003e\n\u003cmeta name=\"version\" content=\"S5 1.0\"\u003e\n\u003clink rel=\"stylesheet\" href=\"ui/my-slides.css\" type=\"text/css\" media=\"projection\" id=\"slideProj\"\u003e\n\u003clink rel=\"stylesheet\" href=\"ui/opera.css\" type=\"text/css\" media=\"projection\" id=\"operaFix\"\u003e\n\u003clink rel=\"stylesheet\" href=\"ui/print.css\" type=\"text/css\" media=\"print\" id=\"slidePrint\"\u003e\n\u003clink rel=\"stylesheet\" href=\"ui/outline.css\" type=\"text/css\" media=\"screen\" id=\"outlineStyle\"\u003e\n\u003cscript src=\"ui/slides.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\u003cstyle type=\"text/css\"\u003e\u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cdiv class=\"layout\"\u003e\n\n\u003cdiv id=\"currentSlide\"\u003e\u003c/div\u003e\n\u003cdiv id=\"header\"\u003e\u003c/div\u003e\n\u003cdiv id=\"footer\"\u003e\n\u003cdiv id=\"controls\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\n\u003c/div\u003e\n\u003cdiv class=\"presentation\"\u003e\n\n\u003cdiv class=\"slide\"\u003e\n\u003cp\u003e\n\u003c/p\u003e\u003ch1\u003eThe uC language\u003c/h1\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003euC is a small subset of C, corresponding to a typical imperative,\nprocedural language.  The following sections describe in more detail\nwhich language elements are present.\u003c/p\u003e\n\n\u003cp\u003eEvery uC program is also a valid C program. The syntax and semantics\nof uC is the same as that for full C, within the restrictions\ndescribed here.\u003c/p\u003e\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eLexical elements\u003c/h1\u003e\n\n\u003cul\u003e\n\u003cli class=\"incremental\"\u003eDecimal integer constants and character literals.\nA character literal contains either a single printable\ncharacter, or the \u003ccode\u003e\\n\u003c/code\u003e escape sequence (line break).\nA character literal denotes an integer constant whose\nvalue is the representation code of the character.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eAlphanumeric identifiers: non-empty sequences of\nletters or digits starting with a letter.\nAn underscore is treated as a letter.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eKeywords: \u003ccode\u003echar\u003c/code\u003e, \u003ccode\u003eelse\u003c/code\u003e, \u003ccode\u003eif\u003c/code\u003e, \u003ccode\u003eint\u003c/code\u003e, \u003ccode\u003ereturn\u003c/code\u003e, \u003ccode\u003evoid\u003c/code\u003e, and \u003ccode\u003ewhile\u003c/code\u003e.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eSpecial symbols:\n\u003ccode\u003e!=\u003c/code\u003e, \u003ccode\u003e!\u003c/code\u003e, \u003ccode\u003e\u0026amp;\u0026amp;\u003c/code\u003e, \u003ccode\u003e(\u003c/code\u003e, \u003ccode\u003e)\u003c/code\u003e, \u003ccode\u003e*\u003c/code\u003e, \u003ccode\u003e+\u003c/code\u003e, \u003ccode\u003e,\u003c/code\u003e (comma), \u003ccode\u003e-\u003c/code\u003e,\n\u003ccode\u003e/\u003c/code\u003e, \u003ccode\u003e;\u003c/code\u003e, \u003ccode\u003e\u0026lt;=\u003c/code\u003e, \u003ccode\u003e\u0026lt;\u003c/code\u003e, \u003ccode\u003e==\u003c/code\u003e,\n\u003ccode\u003e=\u003c/code\u003e, \u003ccode\u003e\u0026gt;=\u003c/code\u003e,\n\u003ccode\u003e\u0026gt;\u003c/code\u003e, \u003ccode\u003e[\u003c/code\u003e, \u003ccode\u003e]\u003c/code\u003e, \u003ccode\u003e{\u003c/code\u003e, \u003ccode\u003e}\u003c/code\u003e.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eWhite space characters: blank (32), newline (10),\ncarriage return (13), form feed (12), and tab (9).\nThe numbers are the ASCII representation codes for the\ncharacters.\n\n\u003cp\u003eComments: \u003ccode\u003e/*\u003c/code\u003e followed by anything and terminated\nby \u003ccode\u003e*/\u003c/code\u003e, and \u003ccode\u003e//\u003c/code\u003e followed by anything\nand terminated by end of line.\u003c/p\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eSyntax\u003c/h1\u003e\n\n\u003cul\u003e\n\u003cli class=\"incremental\"\u003ePrimary expressions: constants, identifiers,\nfunction calls, array indexing, and expressions\nwithin parentheses.\n\n\u003cp\u003eUnary expressions with the \u003ccode\u003e!\u003c/code\u003e and \u003ccode\u003e-\u003c/code\u003e\nunary operators.\u003c/p\u003e\n\n\u003cp\u003eBinary expressions with the \u003ccode\u003e+\u003c/code\u003e, \u003ccode\u003e-\u003c/code\u003e,\n\u003ccode\u003e*\u003c/code\u003e, \u003ccode\u003e/\u003c/code\u003e,\n\u003ccode\u003e\u0026lt;\u003c/code\u003e, \u003ccode\u003e\u0026gt;\u003c/code\u003e,\n\u003ccode\u003e\u0026lt;=\u003c/code\u003e, \u003ccode\u003e\u0026gt;=\u003c/code\u003e,\n\u003ccode\u003e==\u003c/code\u003e,\n\u003ccode\u003e!=\u003c/code\u003e,\n\u003ccode\u003e\u0026amp;\u0026amp;\u003c/code\u003e, and \u003ccode\u003e=\u003c/code\u003e operators.\u003c/p\u003e\n\n\u003cp\u003eStatements: expression statements, the empty statement,\n\u003ccode\u003eif\u003c/code\u003e statements with or without \u003ccode\u003eelse\u003c/code\u003e,\n\u003ccode\u003ewhile\u003c/code\u003e statements, \u003ccode\u003ereturn\u003c/code\u003e statements,\nand compound statements (blocks), i.e., statements\nenclosed in \u003ccode\u003e{ }\u003c/code\u003e.\u003c/p\u003e\n\n\u003cp\u003eLocal variable declarations are only permitted at the\ntop-level function body block, not in nested blocks.\u003c/p\u003e\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eVariable declarations: base type followed by\nvariable name, and for arrays followed by the\narray size (an integer constant) in square brackets.\n\n\u003cp\u003eMulti-dimensional arrays, pointers, and structures\nare not included.\u003c/p\u003e\n\n\u003cp\u003eInitializes in variable declarations are not included.\u003c/p\u003e\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eFunction definitions: return type or \u003ccode\u003evoid\u003c/code\u003e,\nfunction name, parameter list, and body (compound\nstatement) in that order.\n\n\u003cp\u003eThe parameter list is either \u003ccode\u003evoid\u003c/code\u003e, meaning no parameters, or a\nsequence of variable declarations separated by \u003ccode\u003e,\u003c/code\u003e (comma).\nAn array parameter in a function head is written without array\nsize, i.e., with only the brackets.\u003c/p\u003e\n\n\u003cp\u003eAn external (library) function can be declared by writing\na function definition without body, terminated with a\n\u003ccode\u003e;\u003c/code\u003e (semi-colon).\u003c/p\u003e\n\n\u003cp\u003eVariable-arity functions are not included.\u003c/p\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eProgram execution\u003c/h1\u003e\n\n\u003cul\u003e\n\u003cli class=\"incremental\"\u003eExecution starts at the user-defined function \u003ccode\u003emain\u003c/code\u003e\nwhich takes no parameters and returns \u003ccode\u003eint\u003c/code\u003e.\nExecution ends when \u003ccode\u003emain\u003c/code\u003e returns.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eThe standard library is uC-specific since uC excludes\nvariable-arity functions, and this makes \u003ccode\u003eprintf\u003c/code\u003e\nand \u003ccode\u003escanf\u003c/code\u003e-like functions impossible.\nTo use the library, include the following declarations\nat the start of your uC source file:\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003cpre class=\"example\"\u003e        void putint(int i);       // prints to stdout\n        void putstring(char s[]); // prints to stdout\n        int getint(void);         // reads from stdin\n        void getstring(char s[]); // reads from stdin\n\u003c/pre\u003e\n\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eNotes\u003c/h1\u003e\n\n\n\u003cul\u003e\n\u003cli class=\"incremental\"\u003eArray parameters to functions are passed by reference,\nas in full C, but the formal parameter still behaves\nlike an array variable and not as a pointer variable.\nFor example:\n\u003cpre class=\"example\"\u003evoid f(int a[], int b[])\n{\n    a[3] = 27;  // legal\n    a = b;      // illegal in uC, legal in full C\n}\n\u003c/pre\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eExample\u003c/h1\u003e\n\n\n\u003cpre class=\"example\"\u003e/* This is an example uC program. */\nvoid putint(int i);\n\nint fac(int n)\n{\n    if (n \u0026lt; 2)\n        return n;\n    return n * fac(n - 1);\n}\n\nint sum(int n, int a[])\n{\n    int i;\n    int s;\n\n    i = 0;\n    s = 0;\n    while (i \u0026lt; n) {\n        s = s + a[i];\n        i = i + 1;\n    }\n    return s;\n}\n\nint main(void)\n{\n    int a[2];\n\n    a[0] = fac(5);\n    a[1] = 27;\n    putint(sum(2, a)); // prints 147\n    return 0;\n}\n\u003c/pre\u003e\n\n\n\u003c/div\u003e\u003cdiv class=\"slide\"\u003e\n \u003ch1\u003eInformal grammar for uC\u003c/h1\u003e\n\n\u003cp class=\"first\"\u003eThis is an informal context-free grammar for uC:\u003c/p\u003e\n\n\u003cul\u003e\n\u003cli class=\"incremental\"\u003eThe start symbol is \u003ccode\u003eprogram\u003c/code\u003e.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eKeywords and special symbols are written within double-quotes.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003e\u003ccode\u003e/empty/\u003c/code\u003e denotes the empty string.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003e\u003ccode\u003eintconst\u003c/code\u003e and \u003ccode\u003eident\u003c/code\u003e denote classes of lexical elements.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eAssociativity and precedence for expression operators is not expressed.\u003c/li\u003e\n\n\u003cli class=\"incremental\"\u003eThe grammar has not been adjusted to fit any particular parsing method.\u003c/li\u003e\n\u003c/ul\u003e\n\n\n\u003cpre class=\"example\"\u003eprogram         ::= topdec_list\ntopdec_list     ::= /empty/ | topdec topdec_list\ntopdec          ::= vardec \";\"\n                  | funtype ident \"(\" formals \")\" funbody\nvardec          ::= scalardec | arraydec\nscalardec       ::= typename ident\narraydec        ::= typename ident \"[\" intconst \"]\"\ntypename        ::= \"int\" | \"char\"\nfuntype         ::= typename | \"void\"\nfunbody         ::= \"{\" locals stmts \"}\" | \";\"\nformals         ::= \"void\" | formal_list\nformal_list     ::= formaldec | formaldec \",\" formal_list\nformaldec       ::= scalardec | typename ident \"[\" \"]\"\nlocals          ::= /empty/ | vardec \";\" locals\nstmts           ::= /empty/ | stmt stmts\nstmt            ::= expr \";\"\n                  | \"return\" expr \";\" | \"return\" \";\"\n                  | \"while\" condition stmt\n                  | \"if\" condition stmt else_part\n                  | \"{\" stmts \"}\"\n                  | \";\"\nelse_part       ::= /empty/ | \"else\" stmt\ncondition       ::= \"(\" expr \")\"\nexpr            ::= intconst\n                  | ident | ident \"[\" expr \"]\"\n                  | unop expr\n                  | expr binop expr\n                  | ident \"(\" actuals \")\"\n                  | \"(\" expr \")\"\nunop            ::= \"-\" | \"!\"\nbinop           ::= \"+\" | \"-\" | \"*\" | \"/\"\n                  | \"\u0026lt;\" | \"\u0026gt;\" | \"\u0026lt;=\" | \"\u0026gt;=\" | \"!=\" | \"==\"\n                  | \"\u0026amp;\u0026amp;\"\n                  | \"=\"\nactuals         ::= /empty/ | expr_list\nexpr_list       ::= expr | expr \",\" expr_list\n\u003c/pre\u003e\n\n\u003ch3\u003eExpression operator precedence table\u003c/h3\u003e\n\n\u003ch4\u003ePrefix unary operators\u003c/h4\u003e\n\n\u003cp class=\"first\"\u003e14: \u003ccode\u003e-\u003c/code\u003e \u003ccode\u003e!\u003c/code\u003e\u003c/p\u003e\n\n\n\u003ch4\u003eInfix operators\u003c/h4\u003e\n\n\u003cp class=\"first\"\u003e13L: \u003ccode\u003e*\u003c/code\u003e  \u003ccode\u003e/\u003c/code\u003e\u003c/p\u003e\n\n\u003cp\u003e12L: \u003ccode\u003e+\u003c/code\u003e  \u003ccode\u003e-\u003c/code\u003e\u003c/p\u003e\n\n\u003cp\u003e10L: \u003ccode\u003e\u0026lt;\u003c/code\u003e \u003ccode\u003e\u0026gt;\u003c/code\u003e \u003ccode\u003e\u0026lt;=\u003c/code\u003e \u003ccode\u003e\u0026gt;=\u003c/code\u003e\u003c/p\u003e\n\n\u003cp\u003e9L:  \u003ccode\u003e==\u003c/code\u003e \u003ccode\u003e!=\u003c/code\u003e\u003c/p\u003e\n\n\u003cp\u003e5L:  \u003ccode\u003e\u0026amp;\u0026amp;\u003c/code\u003e\u003c/p\u003e\n\n\u003cp\u003e2R:   \u003ccode\u003e=\u003c/code\u003e\u003c/p\u003e\n\n\n\u003cp\u003eThe numbers to the left indicate precedence; larger numbers indicate\nhigher precedence.  L indicates left-associative operators and R\nindicates right-associative operators.  The table only contains the C\noperators that are included in uC.\u003c/p\u003e\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\u003c/body\u003e\u003c/html\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaghettifunk%2Fayec-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspaghettifunk%2Fayec-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspaghettifunk%2Fayec-compiler/lists"}