Skip to main content

A Thai language-localized superset of Python with a bi-directional transformer to standard Python

Project description

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
  • รองรับคำสำคัญภาษาไทย
  • การจัดรูปแบบโค้ด
  • การเยื้องอัตโนมัติ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piyathon-0.3.12.11.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

piyathon-0.3.12.11-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file piyathon-0.3.12.11.tar.gz.

File metadata

  • Download URL: piyathon-0.3.12.11.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for piyathon-0.3.12.11.tar.gz
Algorithm Hash digest
SHA256 a2df9c78db8a0a8b0fb9447245c7ed8a60e29378b077e6c5541a262d0ada3d81
MD5 5044bc6c2d2fef4050ab2be20b704b97
BLAKE2b-256 40d716dcb8f3d1548d4be3d31a3571f7815ada04498b42542060454d65b35a63

See more details on using hashes here.

File details

Details for the file piyathon-0.3.12.11-py3-none-any.whl.

File metadata

  • Download URL: piyathon-0.3.12.11-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for piyathon-0.3.12.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4f32ec02144ac735945aaf9cec3413801b8a8999269164e157f82df7fefd85
MD5 75c4a53ecf746b7eae62440b41df1b7d
BLAKE2b-256 6fde2eb2badab5efcfe1fc8b3cb39176e775991c1ebc8b5208bf06681cfbf57e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page