Metadata-Version: 2.4
Name: parxel
Version: 0.0.21
Summary: A small lexer and parser utility library
Author: styinx
License: MIT License
        
        Copyright (c) 2025 Chris
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/styinx/ParxeL
Project-URL: Issues, https://github.com/styinx/ParxeL/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# ParxeL

A small lexer and parser utility library


## Install

[PyPi](https://pypi.org/project/parxel/0.0.1/)

`pip install parxel`


## Usage

```python
# Import lexer and tokens
from parxel.lexer import Lexer
from parxel.token import Token, TK

# Initialize via file name, path object, file object, or stream
lexer = Lexer(filename=filename, filepath=filepath, file=file, stream=stream)
# List of tokens depends on the defined token types defined in TK
tokens : list[Token] = lexer.tokenize()  # ['token', ' ', 'stream', ';', '...']

# Import parser
from parxel.parser import Parser

# Initialize via tokens, file name, path object, file object, or stream
parser = Parser(tokens=tokens, filename=filename, filepath=filepath, file=file, stream=stream)
parser.parse()  # has to be implemented by the concrete format

# Import nodes to represent the AST
from parxel.nodes import Document

# Sample from md.py
from md import MD

markdown = MD('README.md')
root : Document = markdown.parse()
```


## Sample

Calling:
`python -m md README.md`

Will produce the following AST:
```
MD
 Heading
  Text                bytearray(b' ParxeL')
 Text                bytearray(b'A small lexer and parser utility library')
 Heading
  Text                bytearray(b' Install')
 Reference           bytearray(b'[PyPi](https://pypi.org/project/parxel/0.0.1/)')
 Code                bytearray(b'`pip install parxel`')
 Heading
  Text                bytearray(b' Usage')
 Code                bytearray(b"```python\n# Import lexer and tokens\n [...] root : Document = markdown.parse()\n```")
```

The tokens of LexicalNode's should be processed.
In the above example the raw token stream of the `Text` b' Usage' will be stripped of whitespaces and stored in the `text` property.
Likewise the `Heading` node will contain the indentation level (1, 2, 3, ...) of the heading.
