pyscript-programming-language 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyscript-programming-language might be problematic. Click here for more details.

Files changed (50) hide show
  1. pyscript_programming_language-1.5.1/MANIFEST.in +3 -0
  2. pyscript_programming_language-1.5.1/PKG-INFO +62 -0
  3. pyscript_programming_language-1.5.1/README.md +28 -0
  4. pyscript_programming_language-1.5.1/pyscript/__init__.py +34 -0
  5. pyscript_programming_language-1.5.1/pyscript/__init__.pyi +73 -0
  6. pyscript_programming_language-1.5.1/pyscript/__main__.py +172 -0
  7. pyscript_programming_language-1.5.1/pyscript/core/__init__.py +55 -0
  8. pyscript_programming_language-1.5.1/pyscript/core/analyzer.py +464 -0
  9. pyscript_programming_language-1.5.1/pyscript/core/bases.py +2 -0
  10. pyscript_programming_language-1.5.1/pyscript/core/buffer.py +33 -0
  11. pyscript_programming_language-1.5.1/pyscript/core/cache.py +96 -0
  12. pyscript_programming_language-1.5.1/pyscript/core/constants.py +157 -0
  13. pyscript_programming_language-1.5.1/pyscript/core/context.py +54 -0
  14. pyscript_programming_language-1.5.1/pyscript/core/exceptions.py +110 -0
  15. pyscript_programming_language-1.5.1/pyscript/core/handlers.py +82 -0
  16. pyscript_programming_language-1.5.1/pyscript/core/highlight.py +217 -0
  17. pyscript_programming_language-1.5.1/pyscript/core/interpreter.py +1265 -0
  18. pyscript_programming_language-1.5.1/pyscript/core/lexer.py +813 -0
  19. pyscript_programming_language-1.5.1/pyscript/core/nodes.py +503 -0
  20. pyscript_programming_language-1.5.1/pyscript/core/objects.py +235 -0
  21. pyscript_programming_language-1.5.1/pyscript/core/parser.py +2218 -0
  22. pyscript_programming_language-1.5.1/pyscript/core/position.py +99 -0
  23. pyscript_programming_language-1.5.1/pyscript/core/pysbuiltins.py +345 -0
  24. pyscript_programming_language-1.5.1/pyscript/core/results.py +119 -0
  25. pyscript_programming_language-1.5.1/pyscript/core/runner.py +352 -0
  26. pyscript_programming_language-1.5.1/pyscript/core/symtab.py +105 -0
  27. pyscript_programming_language-1.5.1/pyscript/core/token.py +39 -0
  28. pyscript_programming_language-1.5.1/pyscript/core/utils/__init__.py +13 -0
  29. pyscript_programming_language-1.5.1/pyscript/core/utils/constants.py +152 -0
  30. pyscript_programming_language-1.5.1/pyscript/core/utils/debug.py +35 -0
  31. pyscript_programming_language-1.5.1/pyscript/core/utils/decorators.py +44 -0
  32. pyscript_programming_language-1.5.1/pyscript/core/utils/general.py +139 -0
  33. pyscript_programming_language-1.5.1/pyscript/core/version.py +36 -0
  34. pyscript_programming_language-1.5.1/pyscript/lib/67.pys +1 -0
  35. pyscript_programming_language-1.5.1/pyscript/lib/__hello__.pys +7 -0
  36. pyscript_programming_language-1.5.1/pyscript/lib/brainfuck.pys +195 -0
  37. pyscript_programming_language-1.5.1/pyscript/lib/clock.pys +56 -0
  38. pyscript_programming_language-1.5.1/pyscript/lib/getch.pys +24 -0
  39. pyscript_programming_language-1.5.1/pyscript/lib/jsdict.pys +36 -0
  40. pyscript_programming_language-1.5.1/pyscript/lib/parser.pys +162 -0
  41. pyscript_programming_language-1.5.1/pyscript/lib/sys.pys +17 -0
  42. pyscript_programming_language-1.5.1/pyscript/lib/this.pys +19 -0
  43. pyscript_programming_language-1.5.1/pyscript/this.py +8 -0
  44. pyscript_programming_language-1.5.1/pyscript_programming_language.egg-info/PKG-INFO +62 -0
  45. pyscript_programming_language-1.5.1/pyscript_programming_language.egg-info/SOURCES.txt +48 -0
  46. pyscript_programming_language-1.5.1/pyscript_programming_language.egg-info/dependency_links.txt +1 -0
  47. pyscript_programming_language-1.5.1/pyscript_programming_language.egg-info/requires.txt +3 -0
  48. pyscript_programming_language-1.5.1/pyscript_programming_language.egg-info/top_level.txt +1 -0
  49. pyscript_programming_language-1.5.1/setup.cfg +4 -0
  50. pyscript_programming_language-1.5.1/setup.py +35 -0
@@ -0,0 +1,3 @@
1
+ include README.md
2
+
3
+ recursive-include pyscript/lib *
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyscript-programming-language
3
+ Version: 1.5.1
4
+ Summary: PyScript Programming Language
5
+ Home-page: https://github.com/azzammuhyala/pyscript
6
+ Author: azzammuhyala
7
+ Author-email: azzammuhyala@gmail.com
8
+ License: MIT
9
+ Project-URL: Source, https://github.com/azzammuhyala/pyscript
10
+ Project-URL: Bug Tracker, https://github.com/azzammuhyala/pyscript/issues
11
+ Keywords: pyscript,pys,programming,language,programming language
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Software Development :: Interpreters
17
+ Classifier: Topic :: Software Development :: Compilers
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Provides-Extra: typecheck
21
+ Requires-Dist: beartype; extra == "typecheck"
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license
30
+ Dynamic: project-url
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # PyScript
36
+
37
+ <p align="center">
38
+ <img src="https://github.com/azzammuhyala/pyscript/blob/main/PyScript.png?raw=true" alt="PyScript Logo" width="200">
39
+ </p>
40
+
41
+ PyScript is a simple programming language built on top of Python. It combines some syntax from Python and JavaScript,
42
+ so if you're already familiar with Python or JavaScript, or both, it should be quite easy to learn.
43
+
44
+ ## Introduction PyScript
45
+ PyScript may not be the language we'll be discussing, but the name PyScript already exists, a flexible and platform for
46
+ running Python in a browser. Since it's inception, the language was inspired by Python and JavaScript, which are
47
+ relatively easy for humans to read. This name was chosen because it wasn't immediately known whether this name was
48
+ already in use.
49
+
50
+ This language wasn't designed to compete with other modern programming languages, but rather as a learning for
51
+ understanding how programming languages ​​work and how human written code can be understood by machines. Furthermore, this
52
+ language was created as a relatively complex project. Using Python as the foundation for PyScript, it's easy to
53
+ understand syntax makes it easy to understand how the language is built without having to understand complex
54
+ instructions like those in C, C++, and other low-level languages.
55
+
56
+ To learn more about PyScript, you can see on [PyScript documentation here](https://azzammuhyala.github.io/pyscript) or
57
+ [PyScript repository](https://github.com/azzammuhyala/pyscript).
58
+
59
+ ## Behind it
60
+ This language created from based up on a
61
+ [YouTube tutorial](https://www.youtube.com/playlist?list=PLZQftyCk7_SdoVexSmwy_tBgs7P0b97yD). At least, it takes
62
+ about 6 months to learn it, and also need to learn general things that exist in other programming languages.
@@ -0,0 +1,28 @@
1
+ # PyScript
2
+
3
+ <p align="center">
4
+ <img src="https://github.com/azzammuhyala/pyscript/blob/main/PyScript.png?raw=true" alt="PyScript Logo" width="200">
5
+ </p>
6
+
7
+ PyScript is a simple programming language built on top of Python. It combines some syntax from Python and JavaScript,
8
+ so if you're already familiar with Python or JavaScript, or both, it should be quite easy to learn.
9
+
10
+ ## Introduction PyScript
11
+ PyScript may not be the language we'll be discussing, but the name PyScript already exists, a flexible and platform for
12
+ running Python in a browser. Since it's inception, the language was inspired by Python and JavaScript, which are
13
+ relatively easy for humans to read. This name was chosen because it wasn't immediately known whether this name was
14
+ already in use.
15
+
16
+ This language wasn't designed to compete with other modern programming languages, but rather as a learning for
17
+ understanding how programming languages ​​work and how human written code can be understood by machines. Furthermore, this
18
+ language was created as a relatively complex project. Using Python as the foundation for PyScript, it's easy to
19
+ understand syntax makes it easy to understand how the language is built without having to understand complex
20
+ instructions like those in C, C++, and other low-level languages.
21
+
22
+ To learn more about PyScript, you can see on [PyScript documentation here](https://azzammuhyala.github.io/pyscript) or
23
+ [PyScript repository](https://github.com/azzammuhyala/pyscript).
24
+
25
+ ## Behind it
26
+ This language created from based up on a
27
+ [YouTube tutorial](https://www.youtube.com/playlist?list=PLZQftyCk7_SdoVexSmwy_tBgs7P0b97yD). At least, it takes
28
+ about 6 months to learn it, and also need to learn general things that exist in other programming languages.
@@ -0,0 +1,34 @@
1
+ """
2
+ PyScript is a programming language written in Python. \
3
+ This language is not isolated and is directly integrated with the Python's library and namespace levels.
4
+ """
5
+
6
+ if __import__('sys').version_info < (3, 10):
7
+ raise ImportError("Python version 3.10 and above is required to run PyScript")
8
+
9
+ from . import core
10
+
11
+ from .core.constants import DEFAULT, DEBUG, SILENT, RETRES, COMMENT, NO_COLOR, REVERSE_POW_XOR
12
+ from .core.cache import undefined
13
+ from .core.highlight import HLFMT_HTML, HLFMT_ANSI, pys_highlight
14
+ from .core.runner import pys_exec, pys_eval, pys_shell
15
+ from .core.version import version_info, __version__, __date__
16
+
17
+ __all__ = (
18
+ 'core',
19
+ 'DEFAULT',
20
+ 'DEBUG',
21
+ 'SILENT',
22
+ 'RETRES',
23
+ 'COMMENT',
24
+ 'NO_COLOR',
25
+ 'REVERSE_POW_XOR',
26
+ 'HLFMT_HTML',
27
+ 'HLFMT_ANSI',
28
+ 'undefined',
29
+ 'version_info',
30
+ 'pys_highlight',
31
+ 'pys_exec',
32
+ 'pys_eval',
33
+ 'pys_shell'
34
+ )
@@ -0,0 +1,73 @@
1
+ from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal, Optional
2
+
3
+ if TYPE_CHECKING:
4
+ from .core.buffer import PysFileBuffer
5
+ from .core.cache import PysUndefined
6
+ from .core.highlight import _HighlightFormatter
7
+ from .core.position import PysPosition
8
+ from .core.results import PysExecuteResult
9
+ from .core.symtab import PysSymbolTable
10
+ from .core.version import PysVersionInfo
11
+
12
+ from io import IOBase
13
+
14
+ from . import core as core
15
+
16
+ DEFAULT: int
17
+ DEBUG: int
18
+ SILENT: int
19
+ RETRES: int
20
+ COMMENT: int
21
+ NO_COLOR: int
22
+ REVERSE_POW_XOR: int
23
+
24
+ HLFMT_HTML: _HighlightFormatter
25
+ HLFMT_ANSI: _HighlightFormatter
26
+
27
+ undefined: PysUndefined
28
+ version_info: PysVersionInfo
29
+
30
+ def pys_highlight(
31
+ source: str | bytes | bytearray | Iterator | Callable | IOBase | PysFileBuffer,
32
+ format: Optional[
33
+ Callable[
34
+ [
35
+ str | Literal[
36
+ 'start',
37
+ 'bracket-unmatch',
38
+ 'identifier', 'identifier-const', 'identifier-call', 'identifier-class',
39
+ 'keyword', 'keyword-identifier',
40
+ 'number', 'string', 'comment', 'newline',
41
+ 'default',
42
+ 'end'
43
+ ],
44
+ PysPosition,
45
+ str
46
+ ],
47
+ str
48
+ ]
49
+ ] = None,
50
+ max_parenthesis_level: int = 3,
51
+ flags: int = DEFAULT
52
+ ) -> str: ...
53
+
54
+ def pys_exec(
55
+ source: str | bytes | bytearray | Iterator | Callable | IOBase | PysFileBuffer,
56
+ globals: Optional[dict[str, Any] | PysSymbolTable | PysUndefined] = None,
57
+ flags: int = DEFAULT
58
+ ) -> None | PysExecuteResult: ...
59
+
60
+ def pys_eval(
61
+ source: str | bytes | bytearray | Iterator | Callable | IOBase | PysFileBuffer,
62
+ globals: Optional[dict[str, Any] | PysSymbolTable | PysUndefined] = None,
63
+ flags: int = DEFAULT
64
+ ) -> Any | PysExecuteResult: ...
65
+
66
+ def pys_shell(
67
+ globals: Optional[dict[str, Any] | PysSymbolTable | PysUndefined] = None,
68
+ flags: int = DEFAULT
69
+ ) -> int | Any: ...
70
+
71
+ __version__: str
72
+ __date__: str
73
+ __all__: tuple[str]
@@ -0,0 +1,172 @@
1
+ from .core.buffer import PysFileBuffer
2
+ from .core.cache import undefined
3
+ from .core.constants import DEFAULT, DEBUG, NO_COLOR
4
+ from .core.handlers import handle_execute
5
+ from .core.highlight import HLFMT_HTML, HLFMT_ANSI, pys_highlight
6
+ from .core.runner import pys_runner, pys_shell
7
+ from .core.symtab import build_symbol_table
8
+ from .core.utils.general import normalize_path
9
+ from .core.version import __version__
10
+
11
+ from argparse import ArgumentParser
12
+
13
+ from sys import executable, version_info, exit, setrecursionlimit
14
+ from os.path import basename, splitext
15
+
16
+ parser = ArgumentParser(
17
+ prog=splitext(basename(executable))[0] + ' -m pyscript',
18
+ description='PyScript Launcher for Python Version ' + '.'.join(map(str, version_info))
19
+ )
20
+
21
+ parser.add_argument(
22
+ 'file',
23
+ type=str,
24
+ nargs='?',
25
+ default=None,
26
+ help="file path"
27
+ )
28
+
29
+ parser.add_argument(
30
+ '-v', '--version',
31
+ action='version',
32
+ version=f"PyScript {__version__}",
33
+ )
34
+
35
+ parser.add_argument(
36
+ '-c', '--command',
37
+ type=str,
38
+ default=None,
39
+ help="execute PyScript from argument",
40
+ )
41
+
42
+ parser.add_argument(
43
+ '-d', '--debug',
44
+ action='store_true',
45
+ help="set a debug flag, this will remove the assert statement"
46
+ )
47
+
48
+ parser.add_argument(
49
+ '-i', '--inspect',
50
+ action='store_true',
51
+ help="inspect interactively after running a file",
52
+ )
53
+
54
+ parser.add_argument(
55
+ '-l', '--highlight',
56
+ choices=('html', 'ansi'),
57
+ default=None,
58
+ help='generate PyScript highlight code from a file'
59
+ )
60
+
61
+ parser.add_argument(
62
+ '-n', '--no-color',
63
+ action='store_true',
64
+ help="no colorful traceback"
65
+ )
66
+
67
+ parser.add_argument(
68
+ '-r', '--py-recursion',
69
+ type=int,
70
+ default=None,
71
+ help="set a python recursion limit"
72
+ )
73
+
74
+ args = parser.parse_args()
75
+
76
+ if args.highlight and args.file is None:
77
+ parser.error("-l, --highlight: file path require")
78
+
79
+ if args.py_recursion is not None:
80
+ try:
81
+ setrecursionlimit(args.py_recursion)
82
+ except BaseException as e:
83
+ parser.error(f"-r, --py-recursion: {e}")
84
+
85
+ code = 0
86
+ flags = DEFAULT
87
+
88
+ if args.debug:
89
+ flags |= DEBUG
90
+ if args.no_color:
91
+ flags |= NO_COLOR
92
+
93
+ if args.file is not None:
94
+ path = normalize_path(args.file)
95
+
96
+ try:
97
+ with open(path, 'r', encoding='utf-8') as file:
98
+ file = PysFileBuffer(file, path)
99
+
100
+ except FileNotFoundError:
101
+ parser.error(f"can't open file {path!r}: No such file or directory")
102
+
103
+ except PermissionError:
104
+ parser.error(f"can't open file {path!r}: Permission denied.")
105
+
106
+ except IsADirectoryError:
107
+ parser.error(f"can't open file {path!r}: Path is not a file.")
108
+
109
+ except NotADirectoryError:
110
+ parser.error(f"can't open file {path!r}: Attempting to access directory from file.")
111
+
112
+ except (OSError, IOError):
113
+ parser.error(f"can't open file {path!r}: Attempting to access a system directory or file.")
114
+
115
+ except UnicodeDecodeError:
116
+ parser.error(f"can't read file {path!r}: Bad file.")
117
+
118
+ except BaseException as e:
119
+ parser.error(f"file {path!r}: Unexpected error: {e}")
120
+
121
+ if args.highlight:
122
+ try:
123
+ print(
124
+ pys_highlight(
125
+ file,
126
+ HLFMT_HTML if args.highlight == 'html' else HLFMT_ANSI
127
+ )
128
+ )
129
+ except BaseException as e:
130
+ parser.error(f"file {path!r}: Tokenize error: {e}")
131
+
132
+ else:
133
+ symtab = build_symbol_table(file)
134
+ symtab.set('__name__', '__main__')
135
+
136
+ result = pys_runner(
137
+ file=file,
138
+ mode='exec',
139
+ symbol_table=symtab,
140
+ flags=flags
141
+ )
142
+
143
+ code = handle_execute(result)
144
+
145
+ if args.inspect:
146
+ code = pys_shell(
147
+ globals=result.context.symbol_table,
148
+ flags=result.context.flags
149
+ )
150
+
151
+ elif args.command is not None:
152
+ file = PysFileBuffer(args.command)
153
+
154
+ symtab = build_symbol_table(file)
155
+ symtab.set('__name__', '__main__')
156
+
157
+ code = handle_execute(
158
+ pys_runner(
159
+ file=file,
160
+ mode='exec',
161
+ symbol_table=symtab,
162
+ flags=flags
163
+ )
164
+ )
165
+
166
+ else:
167
+ code = pys_shell(
168
+ globals=undefined,
169
+ flags=flags
170
+ )
171
+
172
+ exit(code)
@@ -0,0 +1,55 @@
1
+ """
2
+ PyScript implementations.
3
+ """
4
+
5
+ from . import (
6
+ analyzer,
7
+ bases,
8
+ buffer,
9
+ cache,
10
+ constants,
11
+ context,
12
+ exceptions,
13
+ handlers,
14
+ highlight,
15
+ interpreter,
16
+ lexer,
17
+ nodes,
18
+ objects,
19
+ parser,
20
+ position,
21
+ pysbuiltins,
22
+ results,
23
+ runner,
24
+ symtab,
25
+ token,
26
+ utils,
27
+ version
28
+ )
29
+
30
+ __all__ = (
31
+ 'analyzer',
32
+ 'bases',
33
+ 'buffer',
34
+ 'cache',
35
+ 'constants',
36
+ 'context',
37
+ 'exceptions',
38
+ 'handlers',
39
+ 'highlight',
40
+ 'immutables',
41
+ 'interpreter',
42
+ 'lexer',
43
+ 'nodes',
44
+ 'objects',
45
+ 'parser',
46
+ 'position',
47
+ 'pysbuiltins',
48
+ 'results',
49
+ 'runner',
50
+ 'singletons',
51
+ 'symtab',
52
+ 'token',
53
+ 'utils',
54
+ 'version'
55
+ )