python / python/cpython

In IDLE colorizer, replace re with tokenizer

Đang mở
#140,347 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

topic-IDLE type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

The current IDLE colorizer was designed when the python grammar was restricted to a context-free subtype. Parsing with RE's was sufficient or closely so to pick out substrings to be color tagged. The current grammar's sometime context-dependence make this more difficult or even impossible.

A few versions ago, the new C tokenizer used to compile Python code was exposed as a function in the tokenizer module. It replaced a python-coded tokenizer that did not always match the old C tokenizer and that must have been much slower. I assume that is was not seen as suitable for IDLE colorizer. However, the current exposed C tokenizer is being used to power the new PyREPL colorizer. The initial (draft) patch copies portions of that colorizer.

My main concerns are compatibility and speed. Some initial questions:

  1. The syntax categories in the REPL colorizer are not the same as IDLE's (listed on the Highlights settings page). What are they?
  2. IDLE colorizes 10000 lines editor contents as well as single interactive lines. Will the PR colorizer do the same, with similar speed?
  3. Is REPL colorizer stable? Are there open bug reports? (Should be labelled topic-repl.) The code is private and undocumented, I presume intentionally, and I do not expect that issues only relevant to IDLE would be welcome.
  4. In the IDLE Issues project, colorizer issues are in Highlights section. Does this fix any, or appear to make fixes easier?
Linked PRs
  • gh-140337
  • gh-152756

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách so sánh colorizer hiện tại dựa trên regex của IDLE với colorizer PyREPL dựa trên tokenizer và module tokenizer được cung cấp. Xem xét các PR được liên kết gh-140337 và gh-152756, sau đó đánh giá tính tương thích của các danh mục cú pháp, hiệu năng của trình soạn thảo với 10.000 dòng, độ ổn định của colorizer REPL và mức độ liên quan đến các issue IDLE Highlights.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
tooling
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.