{"id":17672221,"url":"https://github.com/felixfaisal/syntax-analyzer-rs","last_synced_at":"2025-03-30T15:25:06.706Z","repository":{"id":134542069,"uuid":"435255109","full_name":"felixfaisal/syntax-analyzer-rs","owner":"felixfaisal","description":"A syntax analyzer written in Rust with handwritten logic for validating JSON with trailing commas and comments without using Lex or YACC ","archived":false,"fork":false,"pushed_at":"2022-01-04T11:21:51.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T17:11:32.505Z","etag":null,"topics":["compiler","lexer","parser","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/felixfaisal.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":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-05T19:08:40.000Z","updated_at":"2023-01-28T03:56:23.000Z","dependencies_parsed_at":"2023-06-17T18:33:56.019Z","dependency_job_id":null,"html_url":"https://github.com/felixfaisal/syntax-analyzer-rs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfaisal%2Fsyntax-analyzer-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfaisal%2Fsyntax-analyzer-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfaisal%2Fsyntax-analyzer-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixfaisal%2Fsyntax-analyzer-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixfaisal","download_url":"https://codeload.github.com/felixfaisal/syntax-analyzer-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246336226,"owners_count":20761008,"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":["compiler","lexer","parser","rust"],"created_at":"2024-10-24T04:07:23.699Z","updated_at":"2025-03-30T15:25:06.681Z","avatar_url":"https://github.com/felixfaisal.png","language":"Rust","readme":"# Syntax-Analyzer-rs\nA Rust binary crate that is used to validate JSON files with trailing commas,comments and multiline strings.\n\nIn order to solve this challenge, I'm using basics of Compiler Design concepts. So the program is divided into two parts \n    - Tokenizer (Lexical Analyzer)\n    - Parser (Syntax Analyzer)\n\n### Tokenizer\nThis scans the file and identifies tokens, So currently as of writing this. We are looking for the following tokens\n```rust\npub enum TokenTypes {\n    LeftBrace = 0, \\\\ {\n    RightBrace,\\\\ }\n    LeftBracket, \\\\ [\n    RightBracket, \\\\ ]\n    Colon, \\\\ :\n    Comma, \\\\ ,\n    String, \n    MultiLineString,\n    Comment,\n}\n```\nAfter getting all the tokens, We send the tokens to the parser\n\n### Parser\nA syntax analyzer basically constructs an **Abstract Syntax Tree** using **Context Free Grammar**. The difference here is that we are using CFG but not creating an AST as that goes beyond the scope of the problem statement. So we can check for productions according to the rules of ANON and parse the entire token list.\n\n\n## How to run\n\n```bash \ncargo run \u003cJSON File Path\u003e\n``` \nHere's an example \n\n```bash\nfelix@felix-TUF-Gaming-FX505DY-FX505DY ~/d/anonvalidator (main)\u003e cargo run testcases/test_4.anon\n   Compiling anonvalidator v0.1.0 (/home/felix/deepsource/anonvalidator)\n    Finished dev [unoptimized + debuginfo] target(s) in 0.38s\n     Running `target/debug/anonvalidator testcases/test_4.anon`\nValid file ✅\n```\n## Test Suite\n\nThere are couple of JSON files already which are being used for testing purposes and have been integrated with GitHub Actions, If you would like to run it locally then use the following command\n\n```bash\ncargo test \n```\n\n**Output**\n\n```bash\nfelix@felix-TUF-Gaming-FX505DY-FX505DY ~/d/anonvalidator (main)\u003e cargo test\n   Compiling anonvalidator v0.1.0 (/home/felix/deepsource/anonvalidator)\n    Finished test [unoptimized + debuginfo] target(s) in 0.47s\n     Running unittests (target/debug/deps/anonvalidator-5e245d5b622a2128)\n\nrunning 5 tests\ntest tests::test_example_2 - should panic ... ok\ntest tests::test_example_1 - should panic ... ok\ntest tests::test_example_3 ... ok\ntest tests::test_example_4 ... ok\ntest tests::test_example ... ok\n\ntest result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixfaisal%2Fsyntax-analyzer-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixfaisal%2Fsyntax-analyzer-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixfaisal%2Fsyntax-analyzer-rs/lists"}