{"id":27298781,"url":"https://github.com/ovidiuiliescu/basicparser","last_synced_at":"2025-10-04T17:46:50.878Z","repository":{"id":214632620,"uuid":"733153948","full_name":"ovidiuiliescu/BasicParser","owner":"ovidiuiliescu","description":"Very simple parser combinator, for learning purposes.","archived":false,"fork":false,"pushed_at":"2023-12-29T12:37:01.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T07:41:45.896Z","etag":null,"topics":["parser"],"latest_commit_sha":null,"homepage":"","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/ovidiuiliescu.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,"zenodo":null}},"created_at":"2023-12-18T17:21:51.000Z","updated_at":"2023-12-29T12:42:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"bdbc7690-ef8d-4691-b297-92f990f75b40","html_url":"https://github.com/ovidiuiliescu/BasicParser","commit_stats":null,"previous_names":["ovidiuiliescu/basicparser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ovidiuiliescu/BasicParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovidiuiliescu%2FBasicParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovidiuiliescu%2FBasicParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovidiuiliescu%2FBasicParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovidiuiliescu%2FBasicParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ovidiuiliescu","download_url":"https://codeload.github.com/ovidiuiliescu/BasicParser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovidiuiliescu%2FBasicParser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278350702,"owners_count":25972671,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"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":["parser"],"created_at":"2025-04-12T00:37:55.694Z","updated_at":"2025-10-04T17:46:50.853Z","avatar_url":"https://github.com/ovidiuiliescu.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A very simple parser combinator\n\nParsing structured text (e.g. program source code) sounds more complicated than it actually is.\n\nThis repo exemplifies how to quickly write a [parser combinator](https://en.wikipedia.org/wiki/Parser_combinator) that can be used to do just that. See also [this video](https://www.youtube.com/watch?v=dDtZLm7HIJs) for a quick overview of what we're trying to achieve.\n\nDesign goals:\n\n - Simple code, minimal comments (let the code do the talking)\n - Clear separation of concerns between classes\n - Easy to adapt to your own needs (core parser functionality is **less than 100 lines**, can be reused in you own projects)\n - Meant to be evocative, not exhaustive (things like error handling are greatly simplified)\n - 100% working, but intentionally incomplete (so you can have fun extending the code and tinkering with it).\n\n## What can it do\nThe code in this repo is able to parse somewhat complex [BASIC programs](https://en.wikipedia.org/wiki/BASIC) such as:\n```\n10 LET SomeVariable = \"John\" + \" \" + \"Smith\"\n20 PRINT \"Hello, \", SomeVariable ,\"! How are you?\" : PRINT \"This is another print statement.\" : LET SomeNumber123 = 37  + 1 * (4 * 5)\n30 FOR ALoopVariable = 37 + SomeNumber123 To 1000\n40 LET Temp = ALoopVariable MOD 5\n50 IF ALoopVariable \u003e 400 AND Temp = 2 THEN PRINT \"This is a conditional print: \", ALoopVariable\n60 NEXT\n```\n\nFeel free to play around and add support for more BASIC features, such as:\n\n - User input via the`INPUT` command  (should be similar to how the `PRINT` command is already parsed)\n - User functions via `DEF FN`(how would you declare and parse user arguments in this case?)\n - Actually running the parsed BASIC programs (the parser returns a mostly-usable [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree), but expression evaluation, not to be confused with expression parsing which is already handled, needs to be carefully thought out)\n\n# What's in the box\n\nThis repo takes the form of a single Visual Studio Solution. The solution itself is split in two parts:\n* A universal parser combinator. Simple, concise, and portable. Can be reused in your own projects if you want to. Not meant to be feature complete.\n* A BASIC program parser. Uses the universal parser functionality to parse actual BASIC programs.\n\nThe relevant files and their descriptions are as follows:\n\n## Universal parser functionality\n\n|File|Description|\n|--|--|\n|Parser.cs| Core parser functionality (`While()`,`Until()`) and combinator (`Union()`,`Optional()`) |\n|ParserExtras.cs| Non-core but widely used parser helpers|\n|TextWithPointer.cs| Represents source code with a \"current pointer\"|\n\n\n## BASIC language parser functionality\nThese files use the universal parser functionality mentioned previously to implement a simple BASIC program parser.\n\n|File|Description|\n|--|--|\n|BasicParser.cs| Used as a high-level wrapper/parser over a BASIC program |\n|BasicProgramEntities.cs| Entities used in `BasicParser.cs`|\n|CommandArgumentsReader.cs| Parser for BASIC command arguments (e.g. PRINT, FOR, LET, etc)|\n|CoreEntitiesReader.cs| Parsers for BASIC entities like string, int, etc|\n|ExpressionReader.cs| Parser for BASIC math-like expressions|\n|ListReader.cs| Parser for BASIC lists, in particular lists of command arguments|\n|Misc.cs| Various helper functions|\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovidiuiliescu%2Fbasicparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovidiuiliescu%2Fbasicparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovidiuiliescu%2Fbasicparser/lists"}