{"id":21893583,"url":"https://github.com/tearth/combasic","last_synced_at":"2026-04-28T00:33:05.475Z","repository":{"id":88795001,"uuid":"126649737","full_name":"Tearth/ComBASIC","owner":"Tearth","description":"Simple BASIC compiler based on the old language dialects.","archived":false,"fork":false,"pushed_at":"2019-07-28T16:12:55.000Z","size":177,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T19:37:22.075Z","etag":null,"topics":["asm","assembler","assembly","ast","basic","c","compiler","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tearth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-03-24T23:51:35.000Z","updated_at":"2023-01-27T20:06:48.000Z","dependencies_parsed_at":"2023-06-25T22:48:12.159Z","dependency_job_id":null,"html_url":"https://github.com/Tearth/ComBASIC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Tearth/ComBASIC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tearth%2FComBASIC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tearth%2FComBASIC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tearth%2FComBASIC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tearth%2FComBASIC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tearth","download_url":"https://codeload.github.com/Tearth/ComBASIC/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tearth%2FComBASIC/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32361477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["asm","assembler","assembly","ast","basic","c","compiler","lexer","parser"],"created_at":"2024-11-28T13:14:58.265Z","updated_at":"2026-04-28T00:33:05.460Z","avatar_url":"https://github.com/Tearth.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ComBASIC\n\nThe simple BASIC compiler written in plain C without any external libraries. It takes BASIC file as input and generates Assembly output code which can be assembled by the NASM/MASM and linked with GoLink or some similar software to the executable file.\n\n# Example usage\n\n```bat\nComBASIC -c -d -i helloworld.bas -o helloworld.asm\nnasm -f win32 helloworld.asm -o helloworld.obj\ngolink /console /entry _main helloworld.obj kernel32.dll user32.dll\nhelloworld.exe\npause\n```\n\n**Available options:**\n  * -h - displays help\n  * -c - runs compilation (requires -i and -o)\n  * -d - displays debug info during compilation (like tokens list, AST tree, ...)\n  * -i - specifies input BASIC file\n  * -o - specifies output ASM file\n\n# Compilation process overview\n\n![compilation process](https://noqw8w.bn.files.1drv.com/y4mMwUAQZsMHK0KO23r6aAd9y0H2ESzhOsUUcnZENJSjPeVLEVdpPy1K0KduUBrh_7ZKsonRIvXwyHIS_MKY5v7-2UAo6AD0SJ1Mis2jb6H4YVBUypWwA7A917ewUg501ZUrYvTVJBKll5_N8BwRtBNOdYvBcODz8cqHtvt5BT3RqQoH0tk9eodGVpIs9fJ_nqHsMbG1Qfipw5TIBqr4kHI8w/compilation.png)\n\n# Instructions\n\n| Name        | Description | Usage |\n| ------------- | ------- | ---- |\n| CLS          | Clears the console and moves cursor position to the begin. | CLS  |\n| END          | Ends program and exits the console. | END  |\n| REM          | Comment, skipped during compilation. | REM any tokens until the new line chars  |\n| LET          | Assigns an expression to the specified variable. | LET variable = expression  |\n| WHILE ... WEND          | Loops the instruction block until the specified expression is true. | WHILE expression\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eWEND  |\n| FOR ... TO ... STEP ... NEXT          | Loops the instruction block until the expression is less than condition (step is greater than 0) or the expression is greater than the condition (if step is less than 0). Default step is 1. | FOR variable = expression TO expression\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eNEXT\u003cbr\u003e\u003cbr\u003eFOR variable = expression TO expression STEP expression\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eNEXT|\n| IF ... THEN ... ELSE ... END IF         | Just conditional statement. | IF expression THEN\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eEND IF\u003cbr\u003e\u003cbr\u003eIF expression THEN\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eELSE\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;instructions block\u003cbr\u003eEND IF |\n| GOTO          | Jumps to the specified line. | GOTO line_number  |\n| GOSUB ... RETURN          | Stores the current instruction address onto stack and jumps to the specified line. When enters the RETURN, resumes program at the line after GOSUB instruction using the address from the stack. | GOSUB line_number\u003cbr\u003e...\u003cbr\u003einstructions block\u003cbr\u003eRETURN  |\n| PRINT          | Prints the specified content (string or expression) to the console.| PRINT \"Hello \"; 1+3*4, variable, \" World!\"; |\n| INPUT          | Reads numbers from the console to the specified variables. | INPUT \"Prompt message\"; variable1, variable2, variable3 |\n| WAIT          | Pauses the program for the specified milliseconds number. | WAIT expression |\n\n# Operators\n\n| Symbols        | Priority |\n| ------------- | ---- |\n| * /          | 80  |\n| MOD        | 60  |\n| + -          | 50  |\n| \u003c\u003e \u003c \u003c= \u003e \u003e= =        | 30  |\n| AND         | 20  |\n| OR          | 15  |\n| ( )         | 10  |\n\n# Functions\n\n\n| Name        | Description |\n| ----------- | ---- |\n| ABS(value)  | Returns absolute value of the expression passed in the argument.  |\n| RND(max)    | Returns random integer number in the range from 0 to *max*  |\n| TIME()      | Returns current ticks count from OS start (note that there is no 64 bit variable here, so returned value may not be accurate, but enough to calculate short time intervals).  |\n\n# Example application\n\n#### BASIC code\n```basic\n0 REM Application generating random board every one second\n5 REM\n10 CLS\n20 LET width = 120\n30 LET height = 30\n40 FOR y = 1 TO height - 1\n50 FOR x = 1 TO width - 1\n60 LET r = RND(1)\n70 IF r = 1 THEN\n80 PRINT \"O\";\n90 ELSE\n100 PRINT \" \";\n110 END IF\n120 NEXT\n130 PRINT\n140 NEXT\n150 WAIT 1000\n160 GOTO 10\n```\n\n#### Compilator output\n```\nC:\\Users\\Pawel\\Desktop\\GitHub\\ComBASIC\\Test\u003eComBASIC -c -d -i plansza\\plansza.bas -o plansza\\output.asm\nStarting compilation plansza\\plansza.bas...\n--------------------------------------------------------------\nList of generated tokens:\n[3 0] [0 REM] [2 Program] [2 generujacy] [2 co] [2 okreslony] [2 czas] [2 losowa] [2 plansze] [8 END_OF_INSTRUCTION]\n[3 5] [0 REM] [8 END_OF_INSTRUCTION]\n[3 10] [0 CLS] [8 END_OF_INSTRUCTION]\n[3 20] [0 LET] [2 width] [6 =] [3 120] [8 END_OF_INSTRUCTION]\n[3 30] [0 LET] [2 height] [6 =] [3 30] [8 END_OF_INSTRUCTION]\n[3 40] [0 FOR] [2 y] [6 =] [3 1] [0 TO] [2 height] [6 -] [3 1] [8 END_OF_INSTRUCTION]\n[3 50] [0 FOR] [2 x] [6 =] [3 1] [0 TO] [2 width] [6 -] [3 1] [8 END_OF_INSTRUCTION]\n[3 60] [0 LET] [2 r] [6 =] [1 RND] [6 (] [3 1] [6 )] [8 END_OF_INSTRUCTION]\n[3 70] [0 IF] [2 r] [6 =] [3 1] [0 THEN] [8 END_OF_INSTRUCTION]\n[3 80] [0 PRINT] [4 O] [5 ;] [8 END_OF_INSTRUCTION]\n[3 90] [0 ELSE] [8 END_OF_INSTRUCTION]\n[3 100] [0 PRINT] [4  ] [5 ;] [8 END_OF_INSTRUCTION]\n[3 110] [0 END IF] [8 END_OF_INSTRUCTION]\n[3 120] [0 NEXT] [8 END_OF_INSTRUCTION]\n[3 130] [0 PRINT] [8 END_OF_INSTRUCTION]\n[3 140] [0 NEXT] [8 END_OF_INSTRUCTION]\n[3 150] [0 WAIT] [3 1000] [8 END_OF_INSTRUCTION]\n[3 160] [0 GOTO] [3 10] [8 END_OF_INSTRUCTION]\nEnd of tokens list\n120 30 1 height 1 - 1 width 1 - 1 RND r 1 = 1000 Generated abstract syntax tree:\n38\n   21 0\n      29\n   21 5\n      29\n   21 10\n      3\n   21 20\n      20\n         34 width\n         12\n            26 120\n   21 30\n      20\n         34 height\n         12\n            26 30\n   21 40\n      13\n         38\n            34 y\n            12\n               26 1\n         12\n            32\n               26 1\n               34 height\n         38\n            21 50\n               13\n                  38\n                     34 x\n                     12\n                        26 1\n                  12\n                     32\n                        26 1\n                        34 width\n                  38\n                     21 60\n                        20\n                           34 r\n                           12\n                              31\n                                 26 1\n                     21 70\n                        17\n                           12\n                              9\n                                 26 1\n                                 34 r\n                           38\n                              21 80\n                                 28\n                                    34 var0\n                                    24\n                           38\n                              21 100\n                                 28\n                                    34 var1\n                                    24\n            21 130\n               28\n   21 150\n      35\n         12\n            26 1000\n   21 160\n      14\n         34 10\nEnd of abstract syntax tree\nSymbol table:\n0 width 0\n0 height 0\n0 y 0\n0 x 0\n0 r 0\n1 var0 O\n1 var1\nEnd of symbol table\nCompilation done!\n```\n\n#### Running exe:\n![Example 1](https://i.imgur.com/onuflxF.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftearth%2Fcombasic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftearth%2Fcombasic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftearth%2Fcombasic/lists"}