Crates.io | rolyng_basic_make_parser |
lib.rs | rolyng_basic_make_parser |
version | 0.1.2 |
source | src |
created_at | 2023-11-21 17:56:31.476393 |
updated_at | 2023-11-21 17:56:31.476393 |
description | Basic make parser for educational purposes |
homepage | |
repository | |
max_upload_size | |
id | 1044469 |
size | 57,741 |
Parser of basic make syntax for educational purpose
file = {SOI ~ line+ ~ EOI}
line = {(EMPTY_LINE | rule)}
rule = {rule_header ~ recipe}
rule_header = {rule_name ~ ":" ~ dependencies? ~ "\n"}
dependencies = {identifier ~ ("," ~ identifier)*}
rule_name = {identifier}
recipe = {EMPTY_LINE | (recipe_command+)}
recipe_command = { RECIPE_PREFIX ~ shell_command ~ "\n"}
shell_command = @{(!"\n" ~ ANY)+}
identifier = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
RECIPE_PREFIX = _{"\t"}
EMPTY_LINE = _{"\n"}
WHITESPACE = _{ " " }
COMMENT = _{ "#" ~ (!"\n" ~ ANY)*}
./rolyng_basic_make_parser -h or --help or help #show help
./rolyng_basic_make_parser -V #show version
./rolyng_basic_make_parser -f or --file <file> #parse a file
./rolyng_basic_make_parser author #prints author
#comment
aaa: bbb, ccc #comment
echo ab
bbb: adsa
echo bbb
ccc:
echo ccc
cat boba
ddd:
Outputs:
Rule
name: aaa
dependencies: bbb,ccc,
commands:
echo ab
Rule
name: bbb
dependencies: adsa,
commands:
echo bbb
Rule
name: ccc
dependencies:
commands:
echo ccc
cat boba
Rule
name: ddd
dependencies:
commands: