mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-29 22:36:05 +03:00
add main, record, registers, state, state_leaf section headers to pest
This commit is contained in:
parent
08f33eda01
commit
5ae8d550e5
@ -14,10 +14,15 @@ protected_name = {
|
||||
| "import"
|
||||
| "in"
|
||||
| "let"
|
||||
| "main"
|
||||
| "mut"
|
||||
| "private"
|
||||
| "public"
|
||||
| "record"
|
||||
| "registers"
|
||||
| "return"
|
||||
| "state"
|
||||
| "state_leaf"
|
||||
| "static"
|
||||
| "test"
|
||||
| "true"
|
||||
@ -142,8 +147,23 @@ parameter = { identifier ~ ":" ~ type_ }
|
||||
// Declared in sections/section.rs
|
||||
section = { header ~ NEWLINE+ ~ (assignment ~ NEWLINE*)* }
|
||||
|
||||
// Declared in sections/main_.rs
|
||||
main = { "main" }
|
||||
|
||||
// Declared in sections/record.rs
|
||||
record = { "record" }
|
||||
|
||||
// Declared in sections/registers.rs
|
||||
registers = { "registers" }
|
||||
|
||||
// Declared in sections/state.rs
|
||||
state = { "state" }
|
||||
|
||||
// Declared in sections/state_leaf.rs
|
||||
state_leaf = { "state_leaf" }
|
||||
|
||||
// Declared in sections/header.rs
|
||||
header = { "[" ~ identifier ~ "]" }
|
||||
header = { "[" ~ main | record | registers | state | state_leaf | identifier ~ "]" }
|
||||
|
||||
/// Assignments
|
||||
|
||||
|
@ -1,12 +1,18 @@
|
||||
use crate::{ast::Rule, common::Identifier};
|
||||
use crate::{
|
||||
ast::Rule,
|
||||
common::Identifier,
|
||||
sections::{Main, Record, Registers, State, StateLeaf},
|
||||
};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::header))]
|
||||
pub struct Header<'ast> {
|
||||
pub name: Identifier<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
pub enum Header<'ast> {
|
||||
Main(Main<'ast>),
|
||||
Record(Record<'ast>),
|
||||
Registers(Registers<'ast>),
|
||||
State(State<'ast>),
|
||||
StateLeaf(StateLeaf<'ast>),
|
||||
Identifier(Identifier<'ast>),
|
||||
}
|
||||
|
11
leo-inputs/src/sections/main_.rs
Normal file
11
leo-inputs/src/sections/main_.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::main))]
|
||||
pub struct Main<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
@ -1,5 +1,20 @@
|
||||
pub mod header;
|
||||
pub use header::*;
|
||||
|
||||
pub mod main_;
|
||||
pub use main_::*;
|
||||
|
||||
pub mod record;
|
||||
pub use record::*;
|
||||
|
||||
pub mod registers;
|
||||
pub use registers::*;
|
||||
|
||||
pub mod state;
|
||||
pub use state::*;
|
||||
|
||||
pub mod state_leaf;
|
||||
pub use state_leaf::*;
|
||||
|
||||
pub mod section;
|
||||
pub use section::*;
|
||||
|
11
leo-inputs/src/sections/record.rs
Normal file
11
leo-inputs/src/sections/record.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::record))]
|
||||
pub struct Record<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
11
leo-inputs/src/sections/registers.rs
Normal file
11
leo-inputs/src/sections/registers.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::registers))]
|
||||
pub struct Registers<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
11
leo-inputs/src/sections/state.rs
Normal file
11
leo-inputs/src/sections/state.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::state))]
|
||||
pub struct State<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
11
leo-inputs/src/sections/state_leaf.rs
Normal file
11
leo-inputs/src/sections/state_leaf.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use crate::ast::Rule;
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::state_leaf))]
|
||||
pub struct StateLeaf<'ast> {
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
Loading…
Reference in New Issue
Block a user