{"id":15297049,"url":"https://github.com/perrawd/tokenizer.js","last_synced_at":"2026-04-29T11:01:27.681Z","repository":{"id":57329306,"uuid":"402063919","full_name":"perrawd/tokenizer.js","owner":"perrawd","description":"A lexical analysis parser module built with JS.","archived":false,"fork":false,"pushed_at":"2021-10-21T23:51:24.000Z","size":1139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T13:55:49.002Z","etag":null,"topics":["javascript","nodejs","parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/perrawd.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":"2021-09-01T13:06:07.000Z","updated_at":"2022-05-30T13:08:18.000Z","dependencies_parsed_at":"2022-09-01T15:31:34.500Z","dependency_job_id":null,"html_url":"https://github.com/perrawd/tokenizer.js","commit_stats":null,"previous_names":["perrawd/1dv610-lab1-tokenizer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/perrawd/tokenizer.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perrawd%2Ftokenizer.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perrawd%2Ftokenizer.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perrawd%2Ftokenizer.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perrawd%2Ftokenizer.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perrawd","download_url":"https://codeload.github.com/perrawd/tokenizer.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perrawd%2Ftokenizer.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32422532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["javascript","nodejs","parser"],"created_at":"2024-09-30T19:14:48.263Z","updated_at":"2026-04-29T11:01:27.665Z","avatar_url":"https://github.com/perrawd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lexical Analysis\nA module that performs a lexical analysis for a given string with a lexical grammar.  \n\n## 🔨 How to use\n\n1. Instantiate a new lexical grammar object for the grammar to be used for lexical analysis. [Read more](./src/lib/lexical-grammar/README.md)  \n2. Instantiate a new LexicalAnalysis object with a lexical grammar type and the string that is to be analysed.\n\nExample:\n```\n// Import modules.\nimport GrammaticType from '../src/lib/lexical-grammar/lexical-grammar.js'\nimport GRAMMAR_NAME from '../src/lib/lexical-grammar/grammar-name.js'\nimport LexicalAnalysis from '../src/lexical-analysis.js'\n\n// Assign grammar type (optional).\nconst { ARITHMETIC } = GRAMMAR_NAME\n\n// Instantiate a new object for the grammar type to be used.\nconst arithmeticGrammar = new GrammaticType(ARITHMETIC)\n\n// Create a new lexical analysis.\nconst aritmeticAnalysis = new LexicalAnalysis(arithmeticGrammar, '38 + 4')\n\n// Get active token\nconsole.log(aritmeticAnalysis.getActiveToken()) // Token { tokenMatch: 0, tokenType: 'NUMBER', value: '38' }\n\n// Set the current active token to next.\naritmeticAnalysis.setActiveTokenToNext()\n\nconsole.log(aritmeticAnalysis.getActiveToken()) // Token { tokenMatch: 1, tokenType: 'ADD', value: '+' }\n\n// Set the current active token to next (twice).\naritmeticAnalysis.setActiveTokenToNext()\naritmeticAnalysis.setActiveTokenToNext()\n\nconsole.log(aritmeticAnalysis.getActiveToken()) // Token { tokenMatch: 3, tokenType: 'END', value: 'END' }\n\n// Set the current active token to previous.\naritmeticAnalysis.setActiveTokenToPrevious()\n\nconsole.log(aritmeticAnalysis.getActiveToken()) // Token { tokenMatch: 2, tokenType: 'NUMBER', value: '4' }\n\nconsole.table(aritmeticAnalysis.getTokenList()) // Table of token list.\n\n```\n\n## 🧰 Public methods\n\n### getActiveToken()\nReturns the currently active token.\n\n### setActiveTokenToPrevious()\nSets the pointer of the current token to the previous one in the token list.  \nThrows error if first token has been reached. \n\n### setActiveTokenToNext()\nSets the pointer of the current token to the next one in the token list.  \nCreates the next token if needed.  \nThrows error if END token has been reached. \n\n### getTokenList()\nReturns an array of the created tokens.\n\n## ✏️ Add your own grammar\n[Read more](./src/lib/lexical-grammar/README.md)\n\n## ⛩️ Classes\n\n### LexicalAnalysis\nInstantiate a new ```LexicalAnalysis``` object. \n\nConstructor arguments: \n- {LexicalGrammar} ```LexicalGrammar``` The lexical grammar to be used.  \n- {string} The string to be analysed/tokenized.\n\n### LexicalGrammar\nInstantiate a new ```LexicalGrammar``` object. \n\nConstructor arguments: \n- {string} ```GRAMMAR_NAME``` name of the grammar to be used.\n\n### Token\nUsed by ```LexicalAnalysis```.\nInstantiate a new ```Token``` object. \n\nConstructor arguments: \n- {string} ```tokenMatch``` The index of token.  \n- {string} ```tokenType``` The tokenType.  \n- {string} ```value``` The subString.  \n\n## 🚀 Built with: \n- JavaScript (ES6)\n- Node.js\n\n🧪 Tested with:\n- Jest\n\n✍️ Coding standard:\n- @lnu/eslint-config\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperrawd%2Ftokenizer.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperrawd%2Ftokenizer.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperrawd%2Ftokenizer.js/lists"}