golgotha


Namegolgotha JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryA preprocessor to define new operators in any programming language.
upload_time2024-08-31 16:33:48
maintainerWyatt S Carpenter
docs_urlNone
authorWyatt S Carpenter
requires_python>=3
licenseNone
keywords preprocessor operators infix prefix postfix syntax ๐Ÿ’€ ๐Ÿ”ฃ
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ๐Ÿ”ฃ๐Ÿ’€
GOLGOTHA: Define new operators in any language. Do it, coward! Do it now!

(Project status: I consider this project essentially complete and finished, though it may contain minor surprising edge cases and perhaps even bugs. I don't intend to work on this project any more unless to correct those if they are brought to my attention. Also, I don't expect anyone, including myself, to ever use this project again, because I suspect it isn't worth the trouble it may invite. However, who can say?)

Golgotha is a preprocessor for source texts that allows you to define new infix (or prefix or postfix) operators using rules like this:

๐Ÿ”ฃ1$2๐Ÿ”œ2-1

This example would result in all statements like a$b being transformed to b-a.

This is mostly useful for rules like:

๐Ÿ”ฃ1โ‹…2๐Ÿ”œ1.dot(2)

in languages that don't support the correct operators you want.

Most of the time, you'll want the golgotha rule to be as small as possible, and just perform the syntactic sugar transform to a function call defined elsewhere.

All Golgotha rules must start on a new line, and begin with ๐Ÿ”ฃ. They are terminated by a newline as well. Other whitespace is not stripped, although the golgotha rule will be interpreted as though each argument may be surrounded by arbitrary amounts of whitespace, which follow them through transformations. Arguments are represented in the rules by numbers (strings of contiguous numerical digit characters [0-9]).

Note that the whitespace-retention rules can be initially counter-intuitive. For example, with a rule like ๐Ÿ”ฃ1$2๐Ÿ”œ2-1 as before, the sentence "I gave him x$y apples" would become "I gave himy - xapples"; there is whitespace after the x and before the y in the sentence, and so the same thing happens in the result. (Similar to that old observation that )(() is a palindrome but ()() is not โ€” if you agree with that definition of palindrome, I guess.) meanwhile, the rule ๐Ÿ”ฃ 1$2 ๐Ÿ”œ 2-1  would produce "I gave him y-x apples", but then "I gave him (x$y) apples" is out of luck...

Golgotha processing of the source text is double-pass, so Golgotha rules are applied in the source text even before they are specified in the text. However, Golgotha rules are still applied in the ORDER they are specified, so you should put more specific forms first such that they are applied before more general forms. If you have both a $ and a $= operator, specify the $= first.

Golgotha takes multiple files (and/or stdin, which outputs to stdout); however, the rules from each file are isolated to it.

Golgotha has no concept of precedence. This is because it is permissible to apply Golgotha rules to a language text that already has infix operators, and we don't want you to have to respecify those to get correct precedence behavior overall. Therefore all transformations must be fully parenthesized, unless you want the default behavior, which is just always operating on the closest "word" strings. Golgotha has an inherent idea of what characters parenthesize in the sense above. These "parenthors" are (), [], and {}.

In classic applications, word characters would be defined as the alphanumerounderscorics. However, since we live in the future, they're probably actually defined as anything Unicode thinks of as a letter, a digit, or a connector (which includes underscores). For convenience, Golgotha also includes "." as a word character, due to the popularity of that character as the "dot" member access operator (not to be confused with any "dot" scalar product operator), so that eg person1.name โˆ˜ person2.name operates on both of those entities as intended, and not on "name" and "person2" alone.

Golgotha does not recognize strings or quotation marks in any particular way. Hypothetically, I could have introduced the concept of quothors to deal with this, possibly using the character ๐Ÿ†€ to define them, but I chose not to because capturing the proper behavior of string escaping was too finicky and bespoke. However, it's a good candidate for if you were to include Golgotha as a language-aware processing pass in a compiler (this would be known as Your Language's golgotha or Your Compiler's golgothaโ€”this is Golgotha's golgotha, or The Golgotha That Belongs To No One), or for Golgotha+. So, long story short: strings will be processed as plain text. You must surround them with parenthors and make sure unbalanced parenthors in strings don't mess things up.

Golgotha has been engineered to be easy to implement more than anything else. The current implementation is in Python 3. But a faster implementation would probably be easy to make in another language, and probably should be made before Golgotha is integrated into your build pipeline.

Golgotha reads files in UTF-8 outputs in UTF-8. It reads files of any line-termination style (the exact bounds on this are some python implementation details I don't know offhand) and outputs files as LF (not CRLF) line-terminated. As God intended. (I would support both, but that was too much bother.)

Implicitly, we just assume you don't want to deal with any Golgotha rule symbols (๐Ÿ”ฃ๐Ÿ”œ) in the non-Golgotha parts of your program. There is currently no explicit mechanism to deal with that. However, Golgotha symbols on lines not beginning with ๐Ÿ”ฃ will be ignored, so it's a constrained edge case.

Golgotha+ is an UNIMPLEMENTED extension to Golgotha which would allow one to set the word character set with ๐Ÿ”  lines (default ๐Ÿ” ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ except actually the default would be Unicode \w behavior probably, which would be much harder to replicate with a ๐Ÿ”  line); the argument (in ๐Ÿ”ฃ rule lines) character set with ๐Ÿ”ข lines (default 0123456789); and the set of parenthors with ๐Ÿ…ฟ๐Ÿ”š lines (default ๐Ÿ…ฟ(๐Ÿ”š), ๐Ÿ…ฟ[๐Ÿ”š], and ๐Ÿ…ฟ{๐Ÿ”š}). I was going to implement Golgotha+ but then I realized that no one was going to use this software anyway so the use case was literally 0. An instance of Golgotha with Golgotha+ rules applied to overwrite defaults may be called a Golgothoid.

Golgotha is intentionally non-Turing-complete. While Golgotha exposes powerful rewrite rules, and a Golgotha line can be generated from text input using a Golgotha rule, Golgotha rules generated this way are not adopted by the Golgotha preprocessor. However, it would be trivial to invoke Golgotha on a text file in some kind of infinite loop, if you were crazy or something. You could even make it diff the input and output each time, and only continue if they were different. And then you would have, like, lambda calculus. There is no reason to do that.

This Golgotha (name picked at random) is not to be confused with the R Natural Language Processing package Golgotha https://github.com/bnosac/golgotha nor the video game / game engine Golgotha https://github.com/videogamepreservation/golgotha / https://github.com/pgrawehr/golgotha

The slogan of this Golgotha is "Because Jesus died for your syn... tax", but this thoroughly lame pun was considered well after the name was finalized.

This project is available both on GitHub and PyPi

GitHub: https://github.com/wyattscarpenter/golgotha

PyPi: https://pypi.org/project/golgotha/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "golgotha",
    "maintainer": "Wyatt S Carpenter",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "preprocessor, operators, infix, prefix, postfix, syntax, \ud83d\udc80, \ud83d\udd23",
    "author": "Wyatt S Carpenter",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/98/cd/0a0874be26dc762c8a3f8ae48469d618fc88eba9d606cf16f948e3d23577/golgotha-1.0.1.tar.gz",
    "platform": null,
    "description": "\ud83d\udd23\ud83d\udc80\r\nGOLGOTHA: Define new operators in any language. Do it, coward! Do it now!\r\n\r\n(Project status: I consider this project essentially complete and finished, though it may contain minor surprising edge cases and perhaps even bugs. I don't intend to work on this project any more unless to correct those if they are brought to my attention. Also, I don't expect anyone, including myself, to ever use this project again, because I suspect it isn't worth the trouble it may invite. However, who can say?)\r\n\r\nGolgotha is a preprocessor for source texts that allows you to define new infix (or prefix or postfix) operators using rules like this:\r\n\r\n\ud83d\udd231$2\ud83d\udd1c2-1\r\n\r\nThis example would result in all statements like a$b being transformed to b-a.\r\n\r\nThis is mostly useful for rules like:\r\n\r\n\ud83d\udd231\u22c52\ud83d\udd1c1.dot(2)\r\n\r\nin languages that don't support the correct operators you want.\r\n\r\nMost of the time, you'll want the golgotha rule to be as small as possible, and just perform the syntactic sugar transform to a function call defined elsewhere.\r\n\r\nAll Golgotha rules must start on a new line, and begin with \ud83d\udd23. They are terminated by a newline as well. Other whitespace is not stripped, although the golgotha rule will be interpreted as though each argument may be surrounded by arbitrary amounts of whitespace, which follow them through transformations. Arguments are represented in the rules by numbers (strings of contiguous numerical digit characters [0-9]).\r\n\r\nNote that the whitespace-retention rules can be initially counter-intuitive. For example, with a rule like \ud83d\udd231$2\ud83d\udd1c2-1 as before, the sentence \"I gave him x$y apples\" would become \"I gave himy - xapples\"; there is whitespace after the x and before the y in the sentence, and so the same thing happens in the result. (Similar to that old observation that )(() is a palindrome but ()() is not \u2014 if you agree with that definition of palindrome, I guess.) meanwhile, the rule \ud83d\udd23 1$2 \ud83d\udd1c 2-1  would produce \"I gave him y-x apples\", but then \"I gave him (x$y) apples\" is out of luck...\r\n\r\nGolgotha processing of the source text is double-pass, so Golgotha rules are applied in the source text even before they are specified in the text. However, Golgotha rules are still applied in the ORDER they are specified, so you should put more specific forms first such that they are applied before more general forms. If you have both a $ and a $= operator, specify the $= first.\r\n\r\nGolgotha takes multiple files (and/or stdin, which outputs to stdout); however, the rules from each file are isolated to it.\r\n\r\nGolgotha has no concept of precedence. This is because it is permissible to apply Golgotha rules to a language text that already has infix operators, and we don't want you to have to respecify those to get correct precedence behavior overall. Therefore all transformations must be fully parenthesized, unless you want the default behavior, which is just always operating on the closest \"word\" strings. Golgotha has an inherent idea of what characters parenthesize in the sense above. These \"parenthors\" are (), [], and {}.\r\n\r\nIn classic applications, word characters would be defined as the alphanumerounderscorics. However, since we live in the future, they're probably actually defined as anything Unicode thinks of as a letter, a digit, or a connector (which includes underscores). For convenience, Golgotha also includes \".\" as a word character, due to the popularity of that character as the \"dot\" member access operator (not to be confused with any \"dot\" scalar product operator), so that eg person1.name \u2218 person2.name operates on both of those entities as intended, and not on \"name\" and \"person2\" alone.\r\n\r\nGolgotha does not recognize strings or quotation marks in any particular way. Hypothetically, I could have introduced the concept of quothors to deal with this, possibly using the character \ud83c\udd80 to define them, but I chose not to because capturing the proper behavior of string escaping was too finicky and bespoke. However, it's a good candidate for if you were to include Golgotha as a language-aware processing pass in a compiler (this would be known as Your Language's golgotha or Your Compiler's golgotha\u2014this is Golgotha's golgotha, or The Golgotha That Belongs To No One), or for Golgotha+. So, long story short: strings will be processed as plain text. You must surround them with parenthors and make sure unbalanced parenthors in strings don't mess things up.\r\n\r\nGolgotha has been engineered to be easy to implement more than anything else. The current implementation is in Python 3. But a faster implementation would probably be easy to make in another language, and probably should be made before Golgotha is integrated into your build pipeline.\r\n\r\nGolgotha reads files in UTF-8 outputs in UTF-8. It reads files of any line-termination style (the exact bounds on this are some python implementation details I don't know offhand) and outputs files as LF (not CRLF) line-terminated. As God intended. (I would support both, but that was too much bother.)\r\n\r\nImplicitly, we just assume you don't want to deal with any Golgotha rule symbols (\ud83d\udd23\ud83d\udd1c) in the non-Golgotha parts of your program. There is currently no explicit mechanism to deal with that. However, Golgotha symbols on lines not beginning with \ud83d\udd23 will be ignored, so it's a constrained edge case.\r\n\r\nGolgotha+ is an UNIMPLEMENTED extension to Golgotha which would allow one to set the word character set with \ud83d\udd20 lines (default \ud83d\udd20ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ except actually the default would be Unicode \\w behavior probably, which would be much harder to replicate with a \ud83d\udd20 line); the argument (in \ud83d\udd23 rule lines) character set with \ud83d\udd22 lines (default 0123456789); and the set of parenthors with \ud83c\udd7f\ud83d\udd1a lines (default \ud83c\udd7f(\ud83d\udd1a), \ud83c\udd7f[\ud83d\udd1a], and \ud83c\udd7f{\ud83d\udd1a}). I was going to implement Golgotha+ but then I realized that no one was going to use this software anyway so the use case was literally 0. An instance of Golgotha with Golgotha+ rules applied to overwrite defaults may be called a Golgothoid.\r\n\r\nGolgotha is intentionally non-Turing-complete. While Golgotha exposes powerful rewrite rules, and a Golgotha line can be generated from text input using a Golgotha rule, Golgotha rules generated this way are not adopted by the Golgotha preprocessor. However, it would be trivial to invoke Golgotha on a text file in some kind of infinite loop, if you were crazy or something. You could even make it diff the input and output each time, and only continue if they were different. And then you would have, like, lambda calculus. There is no reason to do that.\r\n\r\nThis Golgotha (name picked at random) is not to be confused with the R Natural Language Processing package Golgotha https://github.com/bnosac/golgotha nor the video game / game engine Golgotha https://github.com/videogamepreservation/golgotha / https://github.com/pgrawehr/golgotha\r\n\r\nThe slogan of this Golgotha is \"Because Jesus died for your syn... tax\", but this thoroughly lame pun was considered well after the name was finalized.\r\n\r\nThis project is available both on GitHub and PyPi\r\n\r\nGitHub: https://github.com/wyattscarpenter/golgotha\r\n\r\nPyPi: https://pypi.org/project/golgotha/\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A preprocessor to define new operators in any programming language.",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://github.com/wyattscarpenter/golgotha/blob/master/readme.txt",
        "Homepage": "https://github.com/wyattscarpenter/golgotha",
        "Issues": "https://github.com/wyattscarpenter/golgotha/issues",
        "Repository": "https://github.com/wyattscarpenter/golgotha.git"
    },
    "split_keywords": [
        "preprocessor",
        " operators",
        " infix",
        " prefix",
        " postfix",
        " syntax",
        " \ud83d\udc80",
        " \ud83d\udd23"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dcf9f91b0ebcb9228c05237355dca50f221510d048cb919159bdfc7cd99811a8",
                "md5": "e3dddc815641dd705a20d54854637601",
                "sha256": "10d02d2424c5729ca519c21dd1f7088e5f05c5e3238594896eba24f7c1df94bc"
            },
            "downloads": -1,
            "filename": "golgotha-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e3dddc815641dd705a20d54854637601",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 9460,
            "upload_time": "2024-08-31T16:33:47",
            "upload_time_iso_8601": "2024-08-31T16:33:47.707458Z",
            "url": "https://files.pythonhosted.org/packages/dc/f9/f91b0ebcb9228c05237355dca50f221510d048cb919159bdfc7cd99811a8/golgotha-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98cd0a0874be26dc762c8a3f8ae48469d618fc88eba9d606cf16f948e3d23577",
                "md5": "c40242522d9c81b8c8b574a3a1738d7f",
                "sha256": "73a47e992892c5f82cdfe31c6ca6f9085c7fea24bdbbaac4038fd1e7a722ecb6"
            },
            "downloads": -1,
            "filename": "golgotha-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c40242522d9c81b8c8b574a3a1738d7f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 12732,
            "upload_time": "2024-08-31T16:33:48",
            "upload_time_iso_8601": "2024-08-31T16:33:48.655745Z",
            "url": "https://files.pythonhosted.org/packages/98/cd/0a0874be26dc762c8a3f8ae48469d618fc88eba9d606cf16f948e3d23577/golgotha-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-31 16:33:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wyattscarpenter",
    "github_project": "golgotha",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "golgotha"
}
        
Elapsed time: 1.69048s