Crates.io | recur-func-parser |
lib.rs | recur-func-parser |
version | 0.1.0 |
source | src |
created_at | 2024-11-20 09:44:08.198457 |
updated_at | 2024-11-20 09:44:08.198457 |
description | parser for general/partial recursive functions and their execution |
homepage | |
repository | https://github.com/mshevcenko/recur-func-parser.git |
max_upload_size | |
id | 1454536 |
size | 57,037 |
Repository:
Documentation:
This parser is built for general/partial recursive function parsing. After all functions are parsed, they can be used for calculations. Anyone could practice creating a general recursive function using this parser.
For more information about general recursive function:
zero function marking: "$z"
successor function marking: "$s"
projection function marking: "$p<arguments count>.<argument number>"
composition function marking: "(<func> : <func>, ... , <func>)"
primitive function marking: "[<func> , <func>]"
minimization function marking: "{<func> , <integer>}"
The parsing process follows these steps:
WHITESPACE = _{ " " | NEWLINE | "\t" }
integer = @{ ASCII_DIGIT+ }
identifier = @{ ASCII_ALPHA ~ (ASCII_DIGIT | ASCII_ALPHA)* }
zero = { "$z" }
successor = { "$s" }
projection = ${ "$p" ~ integer ~ "." ~ integer }
composition = { "(" ~ recursive_function ~ ":" ~ recursive_function ~ ("," ~ recursive_function)* ~ ")" }
primitive = { "[" ~ recursive_function ~ "," ~ recursive_function ~ "]" }
minimization = { "{" ~ recursive_function ~ "," ~ integer ~ "}" }
recursive_function = { zero | successor | projection | identifier | composition | primitive | minimization }
functions = { SOI ~ (identifier ~ "=" ~ recursive_function ~ ";")+ ~ EOI }
query = { SOI ~ identifier ~ integer* ~ EOI }
# Show help information
recur-func-parser help
# Show credits information
recur-func-parser credits
# Parse recursive functions
recur-func-parser parse recur_functions.txt
# Parse recursive functions and print result
recur-func-parser parse recur_functions.txt -p
# Parse recursive functions and start execution loop
recur-func-parser parse recur_functions.txt -e
recur-func-parser parse recur_functions.txt -e
Execution loop started. To stop it, type: ':exit'
> addition 4 5
Result: 9
> const2
Result: 2
> subtractionPart 5 7
Result: Undefined