Commit graph

34 commits

Author SHA1 Message Date
Jeong YunWon
f07b97cef3 Fix match parsing 2025-01-22 01:45:40 +09:00
Zanie Blue
b07966695a
Fix TypeAliasName to store name instead of load (#99)
* Fix `TypeAliasName` to store name instead of load

* Update snapshot tests
2023-07-29 14:23:49 +09:00
Zanie Blue
704eb40108
Add parsing of type alias statements i.e. the type keyword (#97)
Extends #95
Closes #82 

Adds parsing of new `type` soft keyword for defining type aliases.

Supports type alias statements as defined in PEP 695 e.g. 

```python
# A non-generic type alias
type IntOrStr = int | str

# A generic type alias
type ListOrSet[T] = list[T] | set[T]

# A type alias that includes a forward reference
type AnimalOrVegetable = Animal | "Vegetable"

# A generic self-referential type alias
type RecursiveList[T] = T | list[RecursiveList[T]]
```

All type parameter kinds are supported as in #95.

Builds on soft keyword abstractions introduced in https://github.com/RustPython/RustPython/pull/4519
2023-07-17 11:00:08 -04:00
Zanie Blue
6980037ad9
Parse type parameters in function definitions (#96)
* Parse type parameters in function definitions
* Add test for combined items
2023-07-15 06:51:32 +09:00
Zanie
d923aa92bb Parse type parameters in class definitions 2023-07-13 08:40:24 -05:00
Zanie
7516c4248c Move type_param stubs into LALRPOP definition 2023-07-11 09:42:45 -05:00
Zanie
30f461b7e9 Revert formatting changes to python.rs 2023-07-10 14:26:45 -05:00
Zanie
7b0aeeec4b Add stub type_params handling for class and function definitions 2023-07-10 14:00:34 -05:00
Zanie
df2b5dfed0 Regenerate code with latest ASDL 2023-07-10 13:45:36 -05:00
Jeong, YunWon
69d27d924c
Rename unconventional nodes (#74) 2023-06-17 01:54:00 +09:00
Steve Shi
a2e3209c42
Replace num-bigint with malachite-bigint (#18)
Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2023-06-02 17:06:18 +09:00
Jeong, YunWon
fdec727f80
New Arguments and Arg/ArgWithDefault AST representation (#59) 2023-06-01 01:15:23 +09:00
Micha Reiser
342cd19f50
Add safety comment 2023-05-31 09:37:48 +02:00
Micha Reiser
4a2c4aad0b
Align MatchCase end location 2023-05-30 17:31:51 +02:00
Micha Reiser
5493c9f4e3
Avoid removing elements from the beginning of a vec (#69) 2023-05-25 19:44:49 +09:00
Micha Reiser
fac0c25343
Update python.rs 2023-05-19 08:08:35 +02:00
Micha Reiser
726884b287
Avoid allocating vecs for each statement 2023-05-18 21:56:17 +02:00
Micha Reiser
851f23668f
Use named parameters to reducue copying 2023-05-18 21:41:06 +02:00
Jeong, YunWon
6c5c311bab
Fix range field order (#56)
* Skip validate_arguments when empty

* Fix `range` field order

* Fix unused variable
2023-05-18 21:44:01 +09:00
Jeong, YunWon
27e3873dc2
Add full-lexer feature (#36) 2023-05-16 02:21:34 +09:00
Micha Reiser
dd4cc25227
Reduce copying elements when parsing (#35) 2023-05-15 23:20:44 +09:00
Micha Reiser
192379cede
Move range from Attributed to Nodes (#22)
* Move `range` from `Attributed` to `Node`s

* No Attributed + custom for Range PoC

* Generate all located variants, generate enum implementations

* Implement `Copy` on simple enums

* Move `Suite` to `ranged` and `located`

* Update tests
---------

Co-authored-by: Jeong YunWon <jeong@youknowone.org>
2023-05-15 15:08:12 +09:00
Jeong YunWon
aabc96dde9 ruff integration support 2023-05-11 04:08:57 +09:00
Jeong YunWon
aa101e4f26 fix ImportDots 2023-05-10 20:31:04 +09:00
Jeong YunWon
6fa3d0f90a Fine-tune int types 2023-05-10 19:33:39 +09:00
Jeong YunWon
455bcc01a0 Give identifier and int ast types 2023-05-10 19:33:39 +09:00
Jeong YunWon
a3d9d8cb14 numerous refactoring
- Split parser core and compiler core. Fix #14
- AST int type to `u32`
- Updated asdl_rs.py and update_asdl.sh fix #6
- Use `ruff_python_ast::SourceLocation` for Python source location. Deleted our own Location.
- Renamed ast::Located to ast::Attributed to distinguish terms for TextSize and SourceLocation
- `ast::<Node>`s for TextSize located ast. `ast::located::<Node>` for Python source located ast.
- And also strictly renaming `located` to refer only python location related interfaces.
- `SourceLocator` to convert locations.
- New `source-code` features of to disable python locations when unnecessary.
- Also including fully merging https://github.com/astral-sh/RustPython/pull/4 closes #9
2023-05-10 14:35:38 +09:00
Jeong YunWon
a14e43e03a Separate byteoffset ast and located ast 2023-05-09 00:21:52 +09:00
Jeong YunWon
f47dfca4e3 Rename compiler Location to TextSize 2023-05-08 03:38:10 +09:00
Micha Reiser
58c35ab458 Replace row/column based Location with byte-offsets. 2023-05-08 03:38:10 +09:00
Jeong YunWon
6d7358090b Refactor ast to hold data as seperated type 2023-05-07 19:20:47 +09:00
Jeong YunWon
e1f70100ac Update parser/build.rs to embed python.rs 2023-05-06 05:28:30 +09:00
Martin Fischer
4f1e7c6291 Fix docs.rs build for rustpython-parser
docs.rs failed to build the documentation of the recently released
rustpython-parser 0.2.0 because the build.rs script couldn't write the
parser.rs file because docs.rs builds the documentation in a sandbox
with a read-only filesystem.

This commit fixes this by writing the parser.rs file to the cargo output
directory instead, as recommended by the docs.rs documentation.[1]

Fixes #4436.

[1]: https://docs.rs/about/builds#read-only-directories
2023-01-11 09:58:10 +01:00
Jeong YunWon
53c48bf6b9 reorganize compiler crates 2022-08-22 04:42:42 +09:00