Skip to main content

Piyathon

Piyathon is a Thai language-localized superset of Python that uses Thai keywords and function names. It employs a sophisticated translation approach combining tokenization and Abstract Syntax Tree (AST) manipulation to convert between standard Python and Piyathon code. This process involves tokenizing the source code, generating an AST, transforming the AST by translating Thai keywords and function names to their English equivalents (or vice versa), and finally generating code in the target language. This method ensures full compatibility with Python's syntax and features while providing a Thai language interface.

The project includes tools for bidirectional translation between Python and Piyathon, as well as a custom interpreter for directly executing Piyathon code. This interpreter leverages the existing Python ecosystem, translating Piyathon to Python on-the-fly before execution. Piyathon also provides Thai translations for built-in functions, constants, and error messages, and supports Thai characters in variable names, function names, and comments.

By reducing language barriers, Piyathon makes programming more accessible to Thai speakers, particularly beginners, while still allowing seamless transition to standard Python. It also enables experienced programmers to write Python code using Thai, potentially increasing productivity and code readability for Thai-speaking development teams.

Installation

Piyathon requires Python 3.12. It can be installed using the following command:

pip install piyathon

VS Code Extension

To get syntax highlighting and language support in Visual Studio Code:

  1. Open VS Code
  2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on macOS)
  3. Search for "Piyathon"
  4. Click Install on the "Piyathon" extension

Alternatively, you can install it by running this command in VS Code's Quick Open (Ctrl+P or Cmd+P on macOS):

ext install piyawish.piyathon-vscode

The extension provides:

  • Syntax highlighting for .pi files
  • Thai keyword support
  • Code formatting
  • Smart indentation

ปิยะธอน

ปิยะธอนเป็นภาษาโปรแกรมที่พัฒนาต่อยอดจากไพธอน โดยใช้คำสำคัญและชื่อฟังก์ชันเป็นภาษาไทย ปิยะธอนใช้วิธีการแปลภาษาที่ซับซ้อน โดยผสมผสานการแยกโทเคน (tokenization) และการจัดการต้นไม้ไวยากรณ์เชิงนามธรรม (Abstract Syntax Tree หรือ AST) เพื่อแปลงระหว่างโค้ดไพธอนมาตรฐานและโค้ดปิยะธอน กระบวนการนี้ประกอบด้วยการแยกโค้ดต้นฉบับเป็นโทเคน การสร้าง AST การแปลง AST โดยแปลคำสำคัญและชื่อฟังก์ชันภาษาไทยเป็นภาษาอังกฤษ (หรือในทางกลับกัน) และสุดท้ายคือการสร้างโค้ดในภาษาเป้าหมาย วิธีการนี้ช่วยให้ปิยะธอนสามารถทำงานร่วมกับไวยากรณ์และคุณสมบัติของไพธอนได้อย่างสมบูรณ์ ในขณะที่ให้อินเทอร์เฟซเป็นภาษาไทย

โครงการนี้มีเครื่องมือสำหรับการแปลสองทิศทางระหว่างไพธอนและปิยะธอน รวมถึงตัวแปลภาษาที่สามารถรันโค้ดปิยะธอนได้โดยตรง ตัวแปลภาษานี้ใช้ประโยชน์จากระบบนิเวศของไพธอนที่มีอยู่แล้ว โดยแปลงปิยะธอนเป็นไพธอนแบบทันทีก่อนการประมวลผล นอกจากนี้ ปิยะธอนยังมีการแปลฟังก์ชันในตัว ค่าคงที่ และข้อความแสดงข้อผิดพลาดเป็นภาษาไทย และรองรับการใช้ตัวอักษรภาษาไทยในชื่อตัวแปร ชื่อฟังก์ชัน และคำอธิบายในโค้ด

ด้วยการลดอุปสรรคทางภาษา ปิยะธอนช่วยให้การเขียนโปรแกรมเข้าถึงได้ง่ายขึ้นสำหรับผู้ใช้ภาษาไทย โดยเฉพาะผู้เริ่มต้น ในขณะเดียวกันก็ยังเอื้อให้สามารถเปลี่ยนไปใช้ไพธอนมาตรฐานได้อย่างราบรื่น นอกจากนี้ ยังช่วยให้โปรแกรมเมอร์ที่มีประสบการณ์สามารถเขียนโค้ดไพธอนโดยใช้ภาษาไทยได้ ซึ่งอาจช่วยเพิ่มประสิทธิภาพและความสามารถในการอ่านโค้ดสำหรับทีมพัฒนาที่ใช้ภาษาไทย

การติดตั้ง

ปิยะธอนต้องการ Python 3.12 สามารถติดตั้งได้โดยใช้คำสั่งต่อไปนี้:

pip install piyathon

ส่วนขยาย VS Code

วิธีติดตั้งส่วนขยายสำหรับ Visual Studio Code เพื่อรองรับการเขียนโค้ดปิยะธอน:

  1. เปิด VS Code
  2. ไปที่มุมมองส่วนขยาย (กด Ctrl+Shift+X หรือ Cmd+Shift+X บน macOS)
  3. ค้นหา "Piyathon"
  4. คลิกติดตั้งที่ส่วนขยาย "Piyathon"

หรือติดตั้งโดยรันคำสั่งนี้ใน Quick Open ของ VS Code (กด Ctrl+P หรือ Cmd+P บน macOS):

ext install piyawish.piyathon-vscode

ส่วนขยายนี้มีคุณสมบัติดังนี้:

  • ไฮไลท์ไวยากรณ์สำหรับไฟล์ .pi
  • รองรับคำสำคัญภาษาไทย
  • การจัดรูปแบบโค้ด
  • การเยื้องอัตโนมัติ

Metadata

Release files for piyathon 0.3.12.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for piyathon 0.3.12.11
File Size Uploaded
piyathon-0.3.12.11.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for piyathon 0.3.12.11
File Interpreter ABI Platform
piyathon-0.3.12.11-py3-none-any.whl Python 3 none any Details

Total release size: 25.1 kB

Release files / piyathon-0.3.12.11.tar.gz

Download URL piyathon-0.3.12.11.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a2df9c78db8a0a8b0fb9447245c7ed8a60e29378b077e6c5541a262d0ada3d81
BLAKE2b-256 checksum
How to use checksums
40d716dcb8f3d1548d4be3d31a3571f7815ada04498b42542060454d65b35a63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / piyathon-0.3.12.11-py3-none-any.whl

Download URL piyathon-0.3.12.11-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c4f32ec02144ac735945aaf9cec3413801b8a8999269164e157f82df7fefd85
BLAKE2b-256 checksum
How to use checksums
6fde2eb2badab5efcfe1fc8b3cb39176e775991c1ebc8b5208bf06681cfbf57e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page