Skip to content
/ pawky Public

Interpreter for a small subset of the AWK language written in Python

License

Notifications You must be signed in to change notification settings

lentil32/pawky

Repository files navigation

Pawky - AWK Interpreter Written in Python

Demo: https://lentil32.streamlit.app/

Overview

This library is an interpreter for a small subset of the AWK language.

Install and use

git clone https://github.com/lentil32/pawky.git
make install
from pawky import AWKInterpreter

awk_script = "<AWK script>"  # Input your script

interpreter = AWKInterpreter(awk_script)
interpreter.set_input(input_data)
interpreter.run()

For more information, please refer to test.py.

Features

  • [X] BEGIN, END blocks
  • [X] Separators: FS, OFS, RS, ORS
  • [X] Variable assignments with operators e.g., =, +=, -=, *=, /=, %=
  • [X] Print statement for multiple expressions
  • [X] Control structures e.g., if-else statements, for loops, break statements
  • [X] Field variables e.g., $0, $1, $2
  • [X] Basic arithmetic operations e.g., +, -, *, /, %
  • [X] Unary operations e.g., !, -
  • [X] Comments
  • [ ] printf function
  • [ ] Regex matching for patterns
  • [ ] Associative arrays
  • [ ] Built-in functions e.g., length(), substr(), tolower(), toupper()
  • [ ] Defining functions
  • [ ] String concatenation

Setup and run tests for development

make setup
make test

About

Interpreter for a small subset of the AWK language written in Python

Topics

Resources

License

Stars

Watchers

Forks