mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 19:58:12 +08:00
Layout language AST building now complete with recursive parsing referenced XML files
This commit is contained in:
@@ -1,23 +1,53 @@
|
||||
use crate::layout_abstract_attributes::*;
|
||||
|
||||
use crate::layout_abstract_types::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LayoutAbstractSyntaxNode {
|
||||
pub namespace: Option<String>,
|
||||
pub enum LayoutAbstractNode {
|
||||
Tag(LayoutAbstractTag),
|
||||
Text(String),
|
||||
}
|
||||
|
||||
impl LayoutAbstractNode {
|
||||
pub fn new_tag(namespace: String, name: String) -> Self {
|
||||
Self::Tag(LayoutAbstractTag::new(namespace, name))
|
||||
}
|
||||
|
||||
pub fn new_text(text: String) -> Self {
|
||||
Self::Text(text)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LayoutAbstractTag {
|
||||
pub namespace: String,
|
||||
pub name: String,
|
||||
pub attributes: Vec<Attribute>,
|
||||
}
|
||||
|
||||
impl LayoutAbstractSyntaxNode {
|
||||
pub fn new(namespace: Option<String>, tag: String, attributes: &Vec<(String, String)>) -> Self {
|
||||
for attribute in attributes {
|
||||
let parsed = parse_attribute(&attribute.1[..]);
|
||||
println!("{} : {:?} -> {:?}", attribute.0, attribute.1, parsed);
|
||||
}
|
||||
|
||||
Self {
|
||||
namespace,
|
||||
name: tag,
|
||||
attributes: Vec::new(),
|
||||
}
|
||||
impl LayoutAbstractTag {
|
||||
pub fn new(namespace: String, name: String) -> Self {
|
||||
Self { namespace, name, attributes: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_attribute(&mut self, attribute: Attribute) {
|
||||
self.attributes.push(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Attribute {
|
||||
pub name: String,
|
||||
pub value: AttributeValue,
|
||||
}
|
||||
|
||||
impl Attribute {
|
||||
pub fn new(name: String, value: AttributeValue) -> Self {
|
||||
Self { name, value }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AttributeValue {
|
||||
VariableParameter(VariableParameter),
|
||||
TypeValue(Vec<TypeValueOrArgument>),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user