Skip to main content

amethyst/
syntax.rs

1#[derive(Debug, PartialEq, Copy, Clone)]
2pub enum Move {
3    Left,
4    Right,
5    Neutral,
6}
7
8#[derive(Debug, PartialEq, Clone)]
9pub struct Transition {
10    pub read_symbol: char,
11    pub write_symbol: char,
12    pub move_symbol: Move,
13    pub new_state: String,
14}
15
16#[derive(Debug, PartialEq, Clone)]
17pub struct State {
18    pub initial: bool,
19    pub transitions: Box<Vec<Transition>>,
20}
21
22#[derive(Debug, PartialEq, Clone)]
23pub enum StateType {
24    Accept(String),
25    Reject(String),
26    State(String, State),
27}
28
29#[derive(Debug, PartialEq, Clone)]
30pub enum MacroType {
31    Complement(String),
32    Intersect(Box<Vec<String>>),
33    Reunion(Box<Vec<String>>),
34    Chain(Box<Vec<String>>),
35    Repeat(String, u32),
36    Move(Move, u32),
37    Override(Move, u32, char),
38    Place(String),
39    Shift(Move, u32),
40}
41
42#[derive(Debug, PartialEq, Clone)]
43pub struct Machine {
44    pub components: Box<Vec<(String, String)>>,
45    pub states: Box<Vec<StateType>>,
46}
47
48#[derive(Debug, PartialEq, Clone)]
49pub enum AutomatonType {
50    Machine(String, Machine),
51    Macro(String, MacroType),
52}
53
54#[derive(Debug, PartialEq)]
55pub struct Program {
56    pub automata: Box<Vec<AutomatonType>>,
57}