Skip to content

Commit 94cfe0a

Browse files
committed
chore: Upgraded rusty_parser to 2024 edition
Had to create an explicit parser implementation for the complex `var_name` parser as a workaround.
1 parent 323daf8 commit 94cfe0a

50 files changed

Lines changed: 587 additions & 542 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rusty_parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rusty_parser"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

rusty_parser/src/parser.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rusty_pc::*;
55

66
use crate::error::ParseErrorPos;
77
use crate::input::RcStringView;
8-
use crate::specific::{create_file_tokenizer, create_string_tokenizer, program_parser_p, Program};
8+
use crate::specific::{Program, create_file_tokenizer, create_string_tokenizer, program_parser_p};
99

1010
/// Parses a QBasic file.
1111
///
@@ -53,9 +53,9 @@ pub fn parse_main_str(input: String) -> Result<Program, ParseErrorPos> {
5353
mod tests {
5454
use rusty_common::*;
5555

56+
use crate::BuiltInSub;
5657
use crate::specific::*;
5758
use crate::test_utils::*;
58-
use crate::BuiltInSub;
5959

6060
#[test]
6161
fn test_parse_fixture_fib() {
@@ -66,11 +66,13 @@ mod tests {
6666
// DECLARE FUNCTION Fib! (N!)
6767
GlobalStatement::function_declaration(
6868
"Fib!".as_name(1, 18),
69-
vec![Parameter::new(
70-
"N".into(),
71-
ParamType::BuiltIn(TypeQualifier::BangSingle, BuiltInStyle::Compact)
72-
)
73-
.at_rc(1, 24)],
69+
vec![
70+
Parameter::new(
71+
"N".into(),
72+
ParamType::BuiltIn(TypeQualifier::BangSingle, BuiltInStyle::Compact)
73+
)
74+
.at_rc(1, 24)
75+
],
7476
),
7577
// PRINT "Enter the number of fibonacci to calculate"
7678
GlobalStatement::Statement(Statement::Print(Print::one(
@@ -148,26 +150,30 @@ mod tests {
148150
Box::new(
149151
Expression::func(
150152
"Fib",
151-
vec![Expression::BinaryExpression(
152-
Operator::Minus,
153-
Box::new("N".as_var_expr(12, 19)),
154-
Box::new(1.as_lit_expr(12, 23)),
155-
ExpressionType::Unresolved
156-
)
157-
.at_rc(12, 21)]
153+
vec![
154+
Expression::BinaryExpression(
155+
Operator::Minus,
156+
Box::new("N".as_var_expr(12, 19)),
157+
Box::new(1.as_lit_expr(12, 23)),
158+
ExpressionType::Unresolved
159+
)
160+
.at_rc(12, 21)
161+
]
158162
)
159163
.at_rc(12, 15)
160164
),
161165
Box::new(
162166
Expression::func(
163167
"Fib",
164-
vec![Expression::BinaryExpression(
165-
Operator::Minus,
166-
Box::new("N".as_var_expr(12, 32)),
167-
Box::new(2.as_lit_expr(12, 36)),
168-
ExpressionType::Unresolved
169-
)
170-
.at_rc(12, 34)]
168+
vec![
169+
Expression::BinaryExpression(
170+
Operator::Minus,
171+
Box::new("N".as_var_expr(12, 32)),
172+
Box::new(2.as_lit_expr(12, 36)),
173+
ExpressionType::Unresolved
174+
)
175+
.at_rc(12, 34)
176+
]
171177
)
172178
.at_rc(12, 28)
173179
),

rusty_parser/src/specific/built_ins/built_in_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::convert::TryFrom;
22

33
use rusty_common::*;
44

5-
use crate::{keyword_enum, BareName, Name, TypeQualifier};
5+
use crate::{BareName, Name, TypeQualifier, keyword_enum};
66

77
keyword_enum!(
88
pub enum BuiltInFunction SORTED_BUILT_IN_FUNCTIONS SORTED_BUILT_IN_FUNCTION_NAMES {

rusty_parser/src/specific/built_ins/close.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn file_handles() -> impl Parser<RcStringView, Output = Expressions, Error = Par
3535
.or_default()
3636
}
3737

38-
fn file_handle_or_expression_p(
39-
) -> impl Parser<RcStringView, Output = ExpressionPos, Error = ParseError> {
38+
fn file_handle_or_expression_p()
39+
-> impl Parser<RcStringView, Output = ExpressionPos, Error = ParseError> {
4040
OrParser::new(vec![
4141
Box::new(file_handle_as_expression_pos_p()),
4242
Box::new(expression_pos_p()),
@@ -50,7 +50,7 @@ mod tests {
5050
use crate::error::ParseError;
5151
use crate::specific::*;
5252
use crate::test_utils::*;
53-
use crate::{assert_parser_err, BuiltInSub, *};
53+
use crate::{BuiltInSub, assert_parser_err, *};
5454

5555
#[test]
5656
fn test_no_args() {

rusty_parser/src/specific/built_ins/color.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod tests {
1414
use crate::error::ParseError;
1515
use crate::specific::Statement;
1616
use crate::test_utils::*;
17-
use crate::{assert_parser_err, parse, BuiltInSub};
17+
use crate::{BuiltInSub, assert_parser_err, parse};
1818

1919
#[test]
2020
fn parse_foreground_only() {

rusty_parser/src/specific/built_ins/common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ fn map_opt_args_to_flags(args: Vec<Option<ExpressionPos>>) -> Expressions {
4343
}
4444

4545
/// Comma separated list of items, allowing items to be missing between commas.
46-
pub fn csv_allow_missing(
47-
) -> impl Parser<RcStringView, Output = Vec<Option<ExpressionPos>>, Error = ParseError> {
46+
pub fn csv_allow_missing()
47+
-> impl Parser<RcStringView, Output = Vec<Option<ExpressionPos>>, Error = ParseError> {
4848
parse_delimited_to_items(opt_zip(expression_pos_p(), comma()), trailing_comma_error())
4949
.or_default()
5050
}
5151

5252
/// Used in `INPUT` and `LINE INPUT`, parsing an optional file number.
53-
pub fn opt_file_handle_comma_p(
54-
) -> impl Parser<RcStringView, Output = Option<Positioned<FileHandle>>, Error = ParseError> {
53+
pub fn opt_file_handle_comma_p()
54+
-> impl Parser<RcStringView, Output = Option<Positioned<FileHandle>>, Error = ParseError> {
5555
seq2(file_handle_p(), comma(), |l, _| l).to_option()
5656
}
5757

rusty_parser/src/specific/built_ins/def_seg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub fn parse() -> impl Parser<RcStringView, Output = Statement, Error = ParseErr
1616
)
1717
}
1818

19-
fn equal_sign_and_expression(
20-
) -> impl Parser<RcStringView, Output = ExpressionPos, Error = ParseError> {
19+
fn equal_sign_and_expression()
20+
-> impl Parser<RcStringView, Output = ExpressionPos, Error = ParseError> {
2121
equal_sign()
2222
.and_keep_right(expression_pos_p().or_syntax_error("Expected expression after equal sign"))
2323
}

rusty_parser/src/specific/built_ins/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod tests {
2727
use crate::error::ParseError;
2828
use crate::specific::*;
2929
use crate::test_utils::*;
30-
use crate::{assert_built_in_sub_call, assert_parser_err, BuiltInSub, *};
30+
use crate::{BuiltInSub, assert_built_in_sub_call, assert_parser_err, *};
3131

3232
#[test]
3333
fn test_parse_one_variable() {

rusty_parser/src/specific/built_ins/line_input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod tests {
2727
use crate::error::ParseError;
2828
use crate::specific::*;
2929
use crate::test_utils::*;
30-
use crate::{assert_built_in_sub_call, assert_parser_err, BuiltInSub, *};
30+
use crate::{BuiltInSub, assert_built_in_sub_call, assert_parser_err, *};
3131
#[test]
3232
fn test_parse_one_variable() {
3333
let input = "LINE INPUT A$";

rusty_parser/src/specific/built_ins/locate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod tests {
1515
use crate::error::ParseError;
1616
use crate::specific::*;
1717
use crate::test_utils::{DemandSingleStatement, ExpressionLiteralFactory};
18-
use crate::{assert_parser_err, parse, BuiltInSub};
18+
use crate::{BuiltInSub, assert_parser_err, parse};
1919
#[test]
2020
fn parse_row() {
2121
let input = "LOCATE 11";

0 commit comments

Comments
 (0)