add tag span

This commit is contained in:
Josh Thomas 2025-01-06 22:39:16 -06:00
parent 43e6ea8054
commit fdf1ebb8db
10 changed files with 20 additions and 18 deletions

View file

@ -93,13 +93,15 @@ impl Parser {
.map(String::from) .map(String::from)
.collect(); .collect();
let tag_name = bits.first().ok_or(ParserError::EmptyTag)?.clone(); let tag_name = bits.first().ok_or(ParserError::EmptyTag)?.clone();
let span = Span::from(token); let span = Span::from(token);
let tag_span = Span::new(*span.start(), tag_name.len() as u32);
let tag = Tag { let tag = Tag {
name: tag_name.clone(), name: tag_name.clone(),
bits: bits.clone(), bits: bits.clone(),
span, span,
tag_span: span, tag_span,
assignment: None, assignment: None,
}; };

View file

@ -17,7 +17,7 @@ nodes:
length: 8 length: 8
tag_span: tag_span:
start: 3 start: 3
length: 8 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:
@ -39,7 +39,7 @@ nodes:
length: 10 length: 10
tag_span: tag_span:
start: 25 start: 25
length: 10 length: 4
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:

View file

@ -17,7 +17,7 @@ nodes:
length: 17 length: 17
tag_span: tag_span:
start: 3 start: 3
length: 17 length: 3
assignment: ~ assignment: ~
nodes: nodes:
- Variable: - Variable:

View file

@ -15,7 +15,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 3 start: 3
length: 24 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:

View file

@ -20,7 +20,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 12 start: 12
length: 24 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Variable: - Variable:
@ -56,7 +56,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 89 start: 89
length: 24 length: 3
assignment: ~ assignment: ~
nodes: nodes:
- Block: - Block:
@ -71,7 +71,7 @@ nodes:
length: 16 length: 16
tag_span: tag_span:
start: 128 start: 128
length: 16 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:
@ -113,7 +113,7 @@ nodes:
length: 19 length: 19
tag_span: tag_span:
start: 196 start: 196
length: 19 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:
@ -146,7 +146,7 @@ nodes:
length: 15 length: 15
tag_span: tag_span:
start: 243 start: 243
length: 15 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:

View file

@ -17,7 +17,7 @@ nodes:
length: 17 length: 17
tag_span: tag_span:
start: 3 start: 3
length: 17 length: 3
assignment: ~ assignment: ~
nodes: nodes:
- Block: - Block:
@ -32,7 +32,7 @@ nodes:
length: 14 length: 14
tag_span: tag_span:
start: 26 start: 26
length: 14 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Variable: - Variable:

View file

@ -25,7 +25,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 51 start: 51
length: 24 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Comment: - Comment:
@ -75,7 +75,7 @@ nodes:
length: 17 length: 17
tag_span: tag_span:
start: 255 start: 255
length: 17 length: 3
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:

View file

@ -17,7 +17,7 @@ nodes:
length: 17 length: 17
tag_span: tag_span:
start: 3 start: 3
length: 17 length: 3
assignment: ~ assignment: ~
nodes: nodes:
- Variable: - Variable:

View file

@ -15,7 +15,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 3 start: 3
length: 24 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text:

View file

@ -105,7 +105,7 @@ nodes:
length: 24 length: 24
tag_span: tag_span:
start: 466 start: 466
length: 24 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Comment: - Comment:
@ -154,7 +154,7 @@ nodes:
length: 16 length: 16
tag_span: tag_span:
start: 624 start: 624
length: 16 length: 2
assignment: ~ assignment: ~
nodes: nodes:
- Text: - Text: