Rename ast to parser
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
f87f4a0262
commit
705c6a8818
18 changed files with 32 additions and 32 deletions
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ForChain {
|
||||
for_block: Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: For {
|
||||
value_ident: [Ident]"value" (7..12),
|
||||
value_expression: VariableAccess(
|
||||
[Ident]"array" (16..21),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (24..25),
|
||||
),
|
||||
},
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"Hi:" (25..28),
|
||||
),
|
||||
Interpolation {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (28..29),
|
||||
),
|
||||
expression: VariableAccess(
|
||||
[Ident]"value" (33..38),
|
||||
),
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (41..42),
|
||||
),
|
||||
},
|
||||
],
|
||||
else_block: Some(
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: ForElse,
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (52..53),
|
||||
),
|
||||
},
|
||||
),
|
||||
else_content: Some(
|
||||
[
|
||||
StaticContent(
|
||||
[Content]"No Content :C" (53..66),
|
||||
),
|
||||
],
|
||||
),
|
||||
end_block: Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (66..67),
|
||||
),
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
Interpolation {
|
||||
prev_whitespace_content: None,
|
||||
expression: FunctionCall {
|
||||
name: [Ident]"foo" (4..7),
|
||||
args: [
|
||||
Operation {
|
||||
op: Times,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(2))]"2" (8..9),
|
||||
value: Integer {
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Integer(3))]"3" (12..13),
|
||||
value: Integer {
|
||||
value: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
FunctionCall {
|
||||
name: [Ident]"bar" (15..18),
|
||||
args: [
|
||||
Operation {
|
||||
op: Plus,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(2))]"2" (19..20),
|
||||
value: Integer {
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
rhs: VariableAccess(
|
||||
[Ident]"baz" (23..26),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
}
|
||||
55
src/parser/snapshots/nomo__parser__tests__check_if_else.snap
Normal file
55
src/parser/snapshots/nomo__parser__tests__check_if_else.snap
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: VariableAccess(
|
||||
[Ident]"foo" (6..9),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (12..13),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"foo" (13..16),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (16..17),
|
||||
),
|
||||
expression: ElseConditional {
|
||||
expression: None,
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (27..28),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"bar" (28..31),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (31..32),
|
||||
),
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: VariableAccess(
|
||||
[Ident]"foo" (6..9),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (12..13),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"foo" (13..16),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (16..17),
|
||||
),
|
||||
expression: ElseConditional {
|
||||
expression: Some(
|
||||
VariableAccess(
|
||||
[Ident]"bar" (28..31),
|
||||
),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]" " (34..35),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"bar" (35..38),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]" " (38..39),
|
||||
),
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast.to_report(input)
|
||||
---
|
||||
[1m[91merror[0m[1m: Standlone action block[0m
|
||||
[1m[94m ╭▸ [0m
|
||||
[1m[94m1[0m [1m[94m│[0m {{ value }}
|
||||
[1m[94m│[0m [1m[91m━━━━━[0m
|
||||
[1m[94m│[0m
|
||||
[1m[94m╰ [0m[1mhelp[0m: If you want to output this expression, add a '=' to the block
|
||||
[1m[91merror[0m[1m: Standlone action block[0m
|
||||
[1m[94m ╭▸ [0m
|
||||
[1m[94m2[0m [1m[94m│[0m {{ value }}
|
||||
[1m[94m│[0m [1m[91m━━━━━[0m
|
||||
[1m[94m╰ [0m[1mhelp[0m: If you want to output this expression, add a '=' to the block
|
||||
[1m[91merror[0m[1m: Standlone action block[0m
|
||||
[1m[94m ╭▸ [0m
|
||||
[1m[94m3[0m [1m[94m│[0m {{ value }}
|
||||
[1m[94m│[0m [1m[91m━━━━━[0m
|
||||
[1m[94m╰ [0m[1mhelp[0m: If you want to output this expression, add a '=' to the block
|
||||
[1m[91merror[0m[1m: Standlone action block[0m
|
||||
[1m[94m ╭▸ [0m
|
||||
[1m[94m4[0m [1m[94m│[0m {{ value }}
|
||||
[1m[94m│[0m [1m[91m━━━━━[0m
|
||||
[1m[94m╰ [0m[1mhelp[0m: If you want to output this expression, add a '=' to the block
|
||||
[1m[91merror[0m[1m: Standlone action block[0m
|
||||
[1m[94m ╭▸ [0m
|
||||
[1m[94m5[0m [1m[94m│[0m {{ value }}
|
||||
[1m[94m│[0m [1m[91m━━━━━[0m
|
||||
[1m[94m╰ [0m[1mhelp[0m: If you want to output this expression, add a '=' to the block
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
Interpolation {
|
||||
prev_whitespace_content: None,
|
||||
expression: Operation {
|
||||
op: Or,
|
||||
lhs: Operation {
|
||||
op: And,
|
||||
lhs: Literal {
|
||||
source: [Literal(Bool(true))]"true" (4..8),
|
||||
value: Bool {
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Bool(false))]"false" (12..17),
|
||||
value: Bool {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
rhs: Operation {
|
||||
op: And,
|
||||
lhs: Operation {
|
||||
op: GreaterOrEqual,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(3))]"3" (21..22),
|
||||
value: Integer {
|
||||
value: 3,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Integer(2))]"2" (26..27),
|
||||
value: Integer {
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
rhs: Operation {
|
||||
op: Equal,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(5))]"5" (31..32),
|
||||
value: Integer {
|
||||
value: 5,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Integer(2))]"2" (36..37),
|
||||
value: Integer {
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
Interpolation {
|
||||
prev_whitespace_content: None,
|
||||
expression: Operation {
|
||||
op: Plus,
|
||||
lhs: Operation {
|
||||
op: Times,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(5))]"5" (4..5),
|
||||
value: Integer {
|
||||
value: 5,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Integer(3))]"3" (8..9),
|
||||
value: Integer {
|
||||
value: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
rhs: Operation {
|
||||
op: Divide,
|
||||
lhs: Literal {
|
||||
source: [Literal(Integer(2))]"2" (12..13),
|
||||
value: Integer {
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
rhs: Literal {
|
||||
source: [Literal(Integer(3))]"3" (16..17),
|
||||
value: Integer {
|
||||
value: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: VariableAccess(
|
||||
[Ident]"foo" (6..9),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"foo" (14..17),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: ElseConditional {
|
||||
expression: Some(
|
||||
VariableAccess(
|
||||
[Ident]"bar" (30..33),
|
||||
),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"bar" (38..41),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: None,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
74
src/parser/snapshots/nomo__parser__tests__simple_if_ast.snap
Normal file
74
src/parser/snapshots/nomo__parser__tests__simple_if_ast.snap
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: ast
|
||||
---
|
||||
TemplateAst {
|
||||
root: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: VariableAccess(
|
||||
[Ident]"foo" (6..9),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (12..25),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
ConditionalChain {
|
||||
chain: [
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: IfConditional {
|
||||
expression: VariableAccess(
|
||||
[Ident]"bar" (31..34),
|
||||
),
|
||||
},
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (37..54),
|
||||
),
|
||||
},
|
||||
ConditionalContent {
|
||||
content: [
|
||||
StaticContent(
|
||||
[Content]"Hiii" (54..58),
|
||||
),
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: Some(
|
||||
[Whitespace]"\n " (58..71),
|
||||
),
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (80..89),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Block {
|
||||
prev_whitespace_content: None,
|
||||
expression: EndBlock,
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n\n " (98..108),
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
Interpolation {
|
||||
prev_whitespace_content: None,
|
||||
expression: VariableAccess(
|
||||
[Ident]"value" (112..117),
|
||||
),
|
||||
post_whitespace_content: Some(
|
||||
[Whitespace]"\n " (120..129),
|
||||
),
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
source: src/parser/mod.rs
|
||||
expression: parsed
|
||||
---
|
||||
ParsedTemplate {
|
||||
tokens: [
|
||||
[LeftDelim]"{{" (0..2),
|
||||
[Whitespace]" " (2..3),
|
||||
[ConditionalIf]"if" (3..5),
|
||||
[Whitespace]" " (5..6),
|
||||
[Ident]"foo" (6..9),
|
||||
[Whitespace]" " (9..10),
|
||||
[RightDelim]"}}" (10..12),
|
||||
[Whitespace]"\n " (12..25),
|
||||
[LeftDelim]"{{" (25..27),
|
||||
[Whitespace]" " (27..28),
|
||||
[ConditionalIf]"if" (28..30),
|
||||
[Whitespace]" " (30..31),
|
||||
[Ident]"bar" (31..34),
|
||||
[Whitespace]" " (34..35),
|
||||
[RightDelim]"}}" (35..37),
|
||||
[Whitespace]"\n " (37..54),
|
||||
[Content]"Hiii" (54..58),
|
||||
[Whitespace]"\n " (58..71),
|
||||
[LeftDelim]"{{" (71..73),
|
||||
[Whitespace]" " (73..74),
|
||||
[End]"end" (74..77),
|
||||
[Whitespace]" " (77..78),
|
||||
[RightDelim]"}}" (78..80),
|
||||
[Whitespace]"\n " (80..89),
|
||||
[LeftDelim]"{{" (89..91),
|
||||
[Whitespace]" " (91..92),
|
||||
[End]"end" (92..95),
|
||||
[Whitespace]" " (95..96),
|
||||
[RightDelim]"}}" (96..98),
|
||||
[Whitespace]"\n\n " (98..108),
|
||||
[LeftDelim]"{{" (108..110),
|
||||
[WantsOutput]"=" (110..111),
|
||||
[Whitespace]" " (111..112),
|
||||
[Ident]"value" (112..117),
|
||||
[Whitespace]" " (117..118),
|
||||
[RightDelim]"}}" (118..120),
|
||||
[Whitespace]"\n " (120..129),
|
||||
],
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue