turing-lib 2.1.0

Turing library for Rust
Documentation
WHITESPACE = _{ " " | "\t" | NEWLINE}
COMMENT = _{ "/"{2} ~ (LETTER | NUMBER | SPACE_SEPARATOR | PUNCTUATION | SYMBOL | " " | "\t" )+ ~ NEWLINE }

state = @{ASCII_ALPHA+ ~ ASCII_DIGIT*}
value = { "0" | "1" }
movement = { "R" | "L" | "H" | "N" | "D" | "I" }
description = @{ SOI ~ ("/" ~ COMMENT)? }

tape = { "{" ~ value* ~ "}" ~ ";" }
final_state = { "F" ~ "=" ~ "{" ~ state ~ ("," ~ state)* ~ "}" ~ ";" }
initial_state = { "I" ~ "=" ~ "{" ~ state ~ "}" ~ ";" }


function_name = @{ ASCII_ALPHA_LOWER ~ (ASCII_ALPHANUMERIC | "_")* }
composition = { "compose" ~ "=" ~ "{" ~ ((function_name ~ ",")*  ~ function_name) ~ "}" ~ ";"}

initial_params = _{
    tape | initial_state | final_state | composition?
}

// Silent rule to accept the initial parameters in any order
// The composition rule is optional
definition = _{
    PUSH(initial_params)
    ~ (
      !PEEK_ALL
      ~ PUSH(initial_params)
    ){3}
  }

instruction = { "(" ~ state ~ "," ~ value ~ "," ~ value ~ "," ~ movement ~ "," ~ state ~ ")" ~ ";" }

instructions = { instruction+ }

file = { description ~ definition ~ instruction* ~ EOI }