{"id":26895874,"url":"https://github.com/mittelmark/ptlex","last_synced_at":"2025-10-19T15:20:03.746Z","repository":{"id":227986282,"uuid":"772868997","full_name":"mittelmark/ptlex","owner":"mittelmark","description":"Lexer generator written in Tcl for Tcl, Python, Perl, R and Ruby","archived":false,"fork":false,"pushed_at":"2024-03-19T05:57:55.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T02:58:53.435Z","etag":null,"topics":["lexer","lexer-parser"],"latest_commit_sha":null,"homepage":"","language":"Tcl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mittelmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-03-16T05:15:49.000Z","updated_at":"2024-04-14T18:42:44.000Z","dependencies_parsed_at":"2024-03-18T09:51:29.161Z","dependency_job_id":null,"html_url":"https://github.com/mittelmark/ptlex","commit_stats":null,"previous_names":["mittelmark/ptlex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mittelmark/ptlex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Fptlex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Fptlex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Fptlex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Fptlex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mittelmark","download_url":"https://codeload.github.com/mittelmark/ptlex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Fptlex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265934262,"owners_count":23852092,"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":["lexer","lexer-parser"],"created_at":"2025-04-01T02:58:55.829Z","updated_at":"2025-10-19T15:20:03.681Z","avatar_url":"https://github.com/mittelmark.png","language":"Tcl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ptlex\n\n## NAME\n\n__ptlex__: Lexer generator written in Tcl for Tcl, Python, Perl, R and Ruby\n\n## SYNOPSIS\n\n```\nptlex --lang LANGUAGE ?-+? FLEXFILE OUTFILE\n```\n\nReads the input FLEXFILE and creates a Script OUTFILE for the given  language.\nThe option `-+` allows you to create an object oriented  scanner for the given\nlanguage.  Possible  languages are currently Tcl, Perl, Python, Ruby. For Tcl,\nPerl and Python as well object oriented lexers can be generated.\n\n## DESCRIPTION\n\nParsing of various input file formats is a challenging  part for  programmers.\nLexers simplify this process by providing a simplified file format to generate\na full  program  using the lexer  generator.  Here an example for a wc-program\nusing the ptlex program first for Tcl:\n\n\n```\n%{\n    global nline nword nchar\n    set nline 0\n    set nword 0\n    set nchar 0\n%}\n\n%option buffersize=1024\n\n%%\n\n\n\\n {\n    incr nline\n    incr nchar\n}\n\n[^ \\t\\n]+ {\n    incr nword\n    incr nchar [string length $yytext]\n}\n\n. {\n    incr nchar\n}\n\n%%\n\nif {[llength $argv] == 0} {\n   puts stderr \"usage wc.tcl inputfile\"\n   exit 0\n}\nyylex [lindex $argv 0]\nputs [format \"%7d %7d %7d %s\" $nline $nword $nchar [lindex $argv 0]]\n```\n\nThis flex-like input file can be translated into a program with the following programm call:\n\n```\nptlex --lang Tcl wc.ftl wc.tcl\n```\n\nIf you would like to have a scanner  which does not write to stdout you should\nremove the  commandline  parsing at the bottom and just  source this file into\nyour  application.  There you then have to call  yylex with the file which you\nwould like to use.\n\n\nFor more examples see the folder  [samples](samples). You can see the commands\nto   convert   these    flex-like   input   files   into   programs   in   the\n[Makefile](Makefile).\n\n## INSTALLATION\n\nOn Unix systems or on Windows with Msys: \n\n- download the file `ptlex.tapp`\n- make it executable  using `chmod`\n- copy it to a folder belonging to your `PATH` variable\n\n## SUPPORTED LANGUAGES\n\nScanner generation is done using the Tcl programming language. Scanners can be\ngenerated for the programming languages Tcl, Perl, Python, R and Ruby. For the\nfirst three as well in an OO-style. See the following summary table.\n\n| Programming Language | Functional-Style | OO-style   | Samples      |\n|:--------------------:|:----------------:|:----------:|:------------:|\n| Perl                 | yes              | yes        | wc, rep, sbs |\n| Python 3             | yes              | yes        | wc, rep, sbs |\n| R                    | yes              | no         | wc, rep      |\n| Ruby                 | yes              | no         | wc, rep, sbs |\n| Tcl                  | yes              | yes (itcl) | wc, rep, sbs |\n\n## OTHER LEXERS\n\n| Lexer                | Programming Language | Link                                  |\n|:---------------------|:---------------------|:--------------------------------------|\n| Flex                 | C/C++                | https://github.com/westes/flex        |\n| Gplex                | C#                   | https://github.com/k-john-gough/gplex | \n| Jflex                | Java                 | https://github.com/jflex-de/jflex     |\n| Tply                 | Pascal               | https://github.com/martok/fpc-tply    |\n| Fickle               | Tcl                  | https://github.com/devnull42/fickle   |\n| Yeti                 | Tcl                  | https://github.com/mittelmark/yeti    |\n\n## LICENSE\n\n```\nBSD 3-Clause License\n\nCopyright (c) 2009-2024, Detlef Groth, University of Potsdam, Germany\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittelmark%2Fptlex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmittelmark%2Fptlex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittelmark%2Fptlex/lists"}