difftreelog
refactor update logos
in: master
10 files changed
cmds/jrsonnet-fmt/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet-fmt/src/main.rs
+++ b/cmds/jrsonnet-fmt/src/main.rs
@@ -647,10 +647,10 @@
fn format(input: &str, opts: &FormatOptions) -> Option<String> {
let (parsed, errors) = jrsonnet_rowan_parser::parse(input);
if !errors.is_empty() {
- let mut builder = ass_stroke::SnippetBuilder::new(input);
+ let mut builder = hi_doc::SnippetBuilder::new(input);
for error in errors {
builder
- .error(ass_stroke::Text::single(
+ .error(hi_doc::Text::single(
format!("{:?}", error.error).chars(),
Default::default(),
))
@@ -661,7 +661,7 @@
.build();
}
let snippet = builder.build();
- let ansi = ass_stroke::source_to_ansi(&snippet);
+ let ansi = hi_doc::source_to_ansi(&snippet);
eprintln!("{ansi}");
// It is possible to recover from this failure, but the output may be broken, as formatter is free to skip
// ERROR rowan nodes.
crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
+++ b/crates/jrsonnet-rowan-parser/src/generated/syntax_kinds.rs
@@ -135,7 +135,7 @@
MULTI_LINE_COMMENT,
#[regex("/\\*/")]
ERROR_COMMENT_TOO_SHORT,
- #[regex("/\\*([^*]|\\*[^/])+")]
+ #[regex("/\\*([^*/]|\\*[^/])+")]
ERROR_COMMENT_UNTERMINATED,
#[token("tailstrict")]
TAILSTRICT_KW,
@@ -178,9 +178,8 @@
ERROR_MISSING_TOKEN,
ERROR_UNEXPECTED_TOKEN,
ERROR_CUSTOM,
- #[doc = r" Also acts as __LAST_TOKEN"]
- #[error]
LEXING_ERROR,
+ __LAST_TOKEN,
SOURCE_FILE,
EXPR,
SUFFIX_INDEX,
crates/jrsonnet-rowan-parser/src/lex.rsdiffbeforeafterboth1use core::ops::Range;2use std::convert::TryFrom;34use logos::Logos;5use rowan::{TextRange, TextSize};67use crate::{8 string_block::{lex_str_block, StringBlockError},9 SyntaxKind,10};1112pub struct Lexer<'a> {13 inner: logos::Lexer<'a, SyntaxKind>,14}1516impl<'a> Lexer<'a> {17 pub fn new(input: &'a str) -> Self {18 Self {19 inner: SyntaxKind::lexer(input),20 }21 }22}2324impl<'a> Iterator for Lexer<'a> {25 type Item = Lexeme<'a>;2627 fn next(&mut self) -> Option<Self::Item> {28 use SyntaxKind::*;2930 let mut kind = self.inner.next()?;31 let text = self.inner.slice();3233 if kind == STRING_BLOCK {34 // We use custom lexer, which skips enough bytes, but not returns error35 // Instead we should call lexer again to verify if there is something wrong with string block36 let mut lexer = logos::Lexer::<SyntaxKind>::new(text);37 // In kinds, string blocks is parsed at least as `|||`38 lexer.bump(3);39 let res = lex_str_block(&mut lexer);40 debug_assert!(lexer.next().is_none(), "str_block is lexed");41 match res {42 Ok(_) => {}43 Err(e) => {44 kind = match e {45 StringBlockError::UnexpectedEnd => ERROR_STRING_BLOCK_UNEXPECTED_END,46 StringBlockError::MissingNewLine => ERROR_STRING_BLOCK_MISSING_NEW_LINE,47 StringBlockError::MissingTermination => {48 ERROR_STRING_BLOCK_MISSING_TERMINATION49 }50 StringBlockError::MissingIndent => ERROR_STRING_BLOCK_MISSING_INDENT,51 }52 }53 }54 }5556 Some(Self::Item {57 kind,58 text,59 range: {60 let Range { start, end } = self.inner.span();6162 TextRange::new(63 TextSize::try_from(start).unwrap(),64 TextSize::try_from(end).unwrap(),65 )66 },67 })68 }69}7071#[derive(Clone, Copy, Debug)]72pub struct Lexeme<'i> {73 pub kind: SyntaxKind,74 pub text: &'i str,75 pub range: TextRange,76}7778pub fn lex(input: &str) -> Vec<Lexeme<'_>> {79 Lexer::new(input).collect()80}1use core::ops::Range;2use std::convert::TryFrom;34use logos::Logos;5use rowan::{TextRange, TextSize};67use crate::{8 string_block::{lex_str_block, StringBlockError},9 SyntaxKind,10};1112pub struct Lexer<'a> {13 inner: logos::Lexer<'a, SyntaxKind>,14}1516impl<'a> Lexer<'a> {17 pub fn new(input: &'a str) -> Self {18 Self {19 inner: SyntaxKind::lexer(input),20 }21 }22}2324impl<'a> Iterator for Lexer<'a> {25 type Item = Lexeme<'a>;2627 fn next(&mut self) -> Option<Self::Item> {28 use SyntaxKind::*;2930 let mut kind = self.inner.next()?;31 let text = self.inner.slice();3233 if kind == Ok(STRING_BLOCK) {34 // We use custom lexer, which skips enough bytes, but not returns error35 // Instead we should call lexer again to verify if there is something wrong with string block36 let mut lexer = logos::Lexer::<SyntaxKind>::new(text);37 // In kinds, string blocks is parsed at least as `|||`38 lexer.bump(3);39 let res = lex_str_block(&mut lexer);40 debug_assert!(lexer.next().is_none(), "str_block is lexed");41 match res {42 Ok(_) => {}43 Err(e) => {44 kind = Ok(match e {45 StringBlockError::UnexpectedEnd => ERROR_STRING_BLOCK_UNEXPECTED_END,46 StringBlockError::MissingNewLine => ERROR_STRING_BLOCK_MISSING_NEW_LINE,47 StringBlockError::MissingTermination => {48 ERROR_STRING_BLOCK_MISSING_TERMINATION49 }50 StringBlockError::MissingIndent => ERROR_STRING_BLOCK_MISSING_INDENT,51 })52 }53 }54 }5556 Some(Self::Item {57 kind: kind.unwrap_or(SyntaxKind::LEXING_ERROR),58 text,59 range: {60 let Range { start, end } = self.inner.span();6162 TextRange::new(63 TextSize::try_from(start).unwrap(),64 TextSize::try_from(end).unwrap(),65 )66 },67 })68 }69}7071#[derive(Clone, Copy, Debug)]72pub struct Lexeme<'i> {73 pub kind: SyntaxKind,74 pub text: &'i str,75 pub range: TextRange,76}7778pub fn lex(input: &str) -> Vec<Lexeme<'_>> {79 Lexer::new(input).collect()80}crates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -57,7 +57,7 @@
fn from(val: LocatedSyntaxError) -> Self {
let span = SourceSpan::new(
SourceOffset::from(usize::from(val.range.start())),
- SourceOffset::from(usize::from(val.range.end() - val.range.start())),
+ usize::from(val.range.end() - val.range.start()),
);
dbg!(&val);
match val.error {
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__continue_after_total_failure.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__continue_after_total_failure.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__continue_after_total_failure.snap
@@ -65,10 +65,10 @@
LocatedSyntaxError { error: Custom { error: "unexpected tokens after end" }, range: 29..67 }
===
x syntax error
- ,-[1:1]
+ ,-[1:15]
1 | ,-> local intr = $intrinsic(test);
- : || ^^^^|^^^^
- : || `-- expected L_BRACK, L_PAREN, L_BRACE, SEMI, DOT, COMMA or QUESTION_MARK, found IDENT
+ : | ^^^^|^^^^
+ : | `-- expected L_BRACK, L_PAREN, L_BRACE, SEMI, DOT, COMMA or QUESTION_MARK, found IDENT
2 | |
3 | | local a = 1, b = 2, c = a + b;
4 | |
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__local_no_value_recovery.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__local_no_value_recovery.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__local_no_value_recovery.snap
@@ -40,7 +40,7 @@
LocatedSyntaxError { error: Missing { expected: Named("expression") }, range: 25..25 }
===
x syntax error
- ,-[2:1]
+ ,-[3:3]
2 | local b = 3;
3 | 1
: ^^
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__unexpected_destruct.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__unexpected_destruct.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__unexpected_destruct.snap
@@ -26,7 +26,7 @@
LocatedSyntaxError { error: Unexpected { expected: Named("destruction specifier"), found: MUL }, range: 6..7 }
===
x syntax error
- ,-[1:1]
+ ,-[1:7]
1 | local * = 1;
: |
: `-- expected destruction specifier, found MUL
crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snapdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snap
+++ b/crates/jrsonnet-rowan-parser/src/snapshots/jrsonnet_rowan_parser__tests__wrong_field_end.snap
@@ -39,7 +39,7 @@
LocatedSyntaxError { error: Unexpected { expected: Named("comma"), found: SEMI }, range: 14..15 }
===
x syntax error
- ,-[1:1]
+ ,-[2:6]
1 | {
2 | a: 1;
: |
xtask/src/sourcegen/kinds.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/kinds.rs
+++ b/xtask/src/sourcegen/kinds.rs
@@ -273,7 +273,7 @@
lit("SINGLE_LINE_HASH_COMMENT") => r"#[^\r\n]*(\r\n|\n)?";
lit("MULTI_LINE_COMMENT") => r"/\*([^*]|\*[^/])*\*/";
error("COMMENT_TOO_SHORT") => r"/\*/";
- error("COMMENT_UNTERMINATED") => r"/\*([^*]|\*[^/])+";
+ error("COMMENT_UNTERMINATED") => r"/\*([^*/]|\*[^/])+";
];
kinds
}
xtask/src/sourcegen/mod.rsdiffbeforeafterboth--- a/xtask/src/sourcegen/mod.rs
+++ b/xtask/src/sourcegen/mod.rs
@@ -149,9 +149,8 @@
#[doc(hidden)]
EOF,
#(#token_kinds,)*
- /// Also acts as __LAST_TOKEN
- #[error]
LEXING_ERROR,
+ __LAST_TOKEN,
#(#nodes,)*
#[doc(hidden)]
__LAST,