8000 Rust: refactor `ast-generator` to have all customization at the start by redsun82 · Pull Request #19861 · github/codeql · GitHub
[go: up one dir, main page]

Skip to content

Rust: refactor ast-generator to have all customization at the start #19861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: redsun82/rust-emission-trait
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions rust/ast-generator/src/field_info.rs
7DA8
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#[derive(Eq, PartialEq)]
pub enum FieldType {
String,
Predicate,
Optional(String),
Body(String),
List(String),
}

pub struct FieldInfo {
pub name: String,
pub ty: FieldType,
}

impl FieldInfo {
pub fn optional(name: &str, ty: &str) -> FieldInfo {
FieldInfo {
name: name.to_string(),
ty: FieldType::Optional(ty.to_string()),
}
}

pub fn body(name: &str, ty: &str) -> FieldInfo {
FieldInfo {
name: name.to_string(),
ty: FieldType::Body(ty.to_string()),
}
}

pub fn string(name: &str) -> FieldInfo {
FieldInfo {
name: name.to_string(),
ty: FieldType::String,
}
}

pub fn predicate(name: &str) -> FieldInfo {
FieldInfo {
name: name.to_string(),
ty: FieldType::Predicate,
}
}

pub fn list(name: &str, ty: &str) -> FieldInfo {
FieldInfo {
name: name.to_string(),
ty: FieldType::List(ty.to_string()),
}
}
}
Loading
0