Skip to main content

Macro parser

Project description

PyPI Version License Python Version

Macro-parser is a Python package that provides a macro parser.

Basic Usage

Installation

Install with pip:

pip install macro-parser

Get Started

If you save the following text as test.txt:

# This is comment
# There are `new_macro` and `renew_macro`
# Its syntax is like Python:
# \new_macro(
# 	\func_name(func_args){
# 		func_body
# 	}
# )
\new_macro(
	\hello(*args){
		for arg in args:
			print('hello', arg)
	}
	\bye(*args){
		for arg in args:
			print('bye', arg)
	}
)#

# Verbatim environment
\verb(\new_macro)
\verb_(\new_macro(\hello(*args){print(args)}))

# Use the personal defined macros
\hello('world', 'iydon', 'vian')
\bye('world', 'iydon', 'vian')

# See what the built-in macors are
Built-in macros: \builtins().

Then you can parse the macros by:

from macro_parser import parse_macro_in

file = 'test.txt'
print(parse_macro_in(file))

Finally, the result is:


\new_macro
\new_macro(\hello(*args){print(args)})

hello world
hello iydon
hello vian

bye world
bye iydon
bye vian


Built-in macros: ('builtins', 'input', 'new_macro', 'parse', 'renew_macro', 'verb', 'verb_').

Project details


Download files

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

Files for macro-parser, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size macro_parser-0.3.1-py3-none-any.whl (5.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size macro-parser-0.3.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page