Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename built-in rules to be all lowercase #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,040 changes: 11 additions & 1,029 deletions core/src/typed/template/mod.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions derive/tests/calc.pest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use common::base as common

~ = common::whitespaces*

program = pest::SOI ~ expr ~ pest::EOI
program = pest::soi ~ expr ~ pest::eoi
expr = prefix* ~ primary ~ postfix* ~ (infix ~ prefix* ~ primary ~ postfix* )*
infix = _{ add | sub | mul | div | pow }
add = "+" // Addition
Expand All @@ -14,4 +14,4 @@ expr = prefix* ~ primary ~ postfix* ~ (infix ~ prefix* ~ primary ~ postf
neg = "-" // Negation
postfix = _{ fac }
fac = "!" // Factorial
primary = _{ common::int | "(" ~ expr ~ ")" }
primary = _{ common::int | "(" ~ expr ~ ")" }
37 changes: 13 additions & 24 deletions derive/tests/grammar.pest
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
// pest. The Elegant Parser
// Copyright (c) 2018 Dragoș Tiselice
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.

// Modified by Boyi Huang (@TheVeryDarkness) when upgrading to pest3.

string = "abc"
insensitive = i"abc"
range = '0'..'9'
Expand All @@ -35,7 +24,7 @@ repeat_min = string~{2..}
repeat_min_atomic = string{2..}
repeat_max = string~{..2}
repeat_max_atomic = string{..2}
soi_at_start = pest::SOI - string
soi_at_start = pest::soi - string
repeat_mutate_stack = (pest::stack::push('a'..'c') - ",")* - pest::stack::pop - pest::stack::pop - pest::stack::pop
repeat_mutate_stack_pop_all = (pest::stack::push('a'..'c') - ",")* - pest::stack::pop_all
will_fail = repeat_mutate_stack_pop_all - "FAIL"
Expand All @@ -46,25 +35,25 @@ peek_slice_23 = pest::stack::push(range) - pest::stack::push(range) - pest::stac
pop_ = pest::stack::push(range) - pest::stack::push(range) - pest::stack::pop - pest::stack::pop
pop_all = pest::stack::push(range) - pest::stack::push(range) - pest::stack::pop_all
pop_fail = pest::stack::push(range) - !pest::stack::pop - range - pest::stack::pop
checkpoint_restore = pest::stack::push("") - (pest::stack::push("a") - "b" - pest::stack::pop | pest::stack::drop - "b" | pest::stack::pop - "a") - pest::EOI
checkpoint_restore = pest::stack::push("") - (pest::stack::push("a") - "b" - pest::stack::pop | pest::stack::drop - "b" | pest::stack::pop - "a") - pest::eoi
longchoice_builtin = ( "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16")
longseq_builtin = ( "01" ~ "02" ~ "03" ~ "04" ~ "05" ~ "06" ~ "07" ~ "08" ~ "09" ~ "10" ~ "11" ~ "12" ~ "13" ~ "14" ~ "15" ~ "16")
longchoice_critical = ( "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17")
longseq_critical = ( "01" ~ "02" ~ "03" ~ "04" ~ "05" ~ "06" ~ "07" ~ "08" ~ "09" ~ "10" ~ "11" ~ "12" ~ "13" ~ "14" ~ "15" ~ "16" ~ "17")
longchoice_jump = ( "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19")
longseq_jump = ( "01" ~ "02" ~ "03" ~ "04" ~ "05" ~ "06" ~ "07" ~ "08" ~ "09" ~ "10" ~ "11" ~ "12" ~ "13" ~ "14" ~ "15" ~ "16" ~ "17" ~ "18" ~ "19")
/*
ascii_digits = ASCII_DIGIT+
ascii_nonzero_digits = ASCII_NONZERO_DIGIT+
ascii_bin_digits = ASCII_BIN_DIGIT+
ascii_oct_digits = ASCII_OCT_DIGIT+
ascii_hex_digits = ASCII_HEX_DIGIT+
ascii_alpha_lowers = ASCII_ALPHA_LOWER+
ascii_alpha_uppers = ASCII_ALPHA_UPPER+
ascii_alphas = ASCII_ALPHA+
ascii_alphanumerics = ASCII_ALPHANUMERIC+
asciis = ASCII+
newline = NEWLINE+
ascii_digits = ascii_digit+
ascii_nonzero_digits = ascii_nonzero_digit+
ascii_bin_digits = ascii_bin_digit+
ascii_oct_digits = ascii_oct_digit+
ascii_hex_digits = ascii_hex_digit+
ascii_alpha_lowers = ascii_alpha_lower+
ascii_alpha_uppers = ascii_alpha_upper+
ascii_alphas = ascii_alpha+
ascii_alphanumerics = ascii_alphanumeric+
asciis = ascii+
newline = newline+
unicode = XID_START - XID_CONTINUE*
SYMBOL = "shadows builtin"

Expand Down
4 changes: 2 additions & 2 deletions derive/tests/json.pest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! A parser for JSON file.
#! A parser for JSON file.
//!
//! And this is a example for JSON parser.
//!
Expand All @@ -8,7 +8,7 @@
// FIXME: some should be under pest::*
use common::base as p

json = pest::SOI ~ value ~ pest::EOI
json = pest::soi ~ value ~ pest::eoi

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Action Required: Remaining uppercase 'SOI' and 'EOI' found

  • File: meta/src/grammar.pest
    • Lines: 2, 4
  • File: generator/tests/syntax.pest
    • Lines: 1, 2

Please update SOI and EOI to lowercase soi and eoi in the above files to ensure consistent usage across the codebase.

🔗 Analysis chain

LGTM: Consistent renaming of built-in rules

The changes from pest::SOI to pest::soi and pest::EOI to pest::eoi are in line with the PR objective of renaming built-in rules to be all lowercase. This change enhances consistency across the codebase.

To ensure these changes are applied consistently across the project, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of lowercase 'soi' and 'eoi' across the project

# Test: Check for any remaining uppercase usage of SOI and EOI
echo "Checking for any remaining uppercase SOI and EOI usage:"
rg -i '\b(SOI|EOI)\b' --type pest

# Test: Confirm the usage of lowercase soi and eoi
echo "Confirming usage of lowercase soi and eoi:"
rg '\b(soi|eoi)\b' --type pest

Length of output: 342


Script:

#!/bin/bash
# Description: Verify consistent usage of lowercase 'soi' and 'eoi' across the project

# Find all .pest files and check for any remaining uppercase SOI and EOI usage
echo "Checking for any remaining uppercase SOI and EOI usage:"
fd --extension pest | xargs rg -i '\b(SOI|EOI)\b'

# Confirm the usage of lowercase soi and eoi
echo "Confirming usage of lowercase soi and eoi:"
fd --extension pest | xargs rg '\b(soi|eoi)\b'

Length of output: 1777

/// Matches object, e.g.: `{ "foo": "bar" }`
/// Foobar
Expand Down
2 changes: 0 additions & 2 deletions generator/src/typed/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ impl<'g> ModuleSystem<'g> {
.collect(),
);
let pest = HashMap::from([
pest_builtin!(SOI {}),
pest_builtin!(EOI {}),
pest_builtin!(soi {}),
pest_builtin!(eoi {}),
pest_builtin!(any {}),
Expand Down
19 changes: 6 additions & 13 deletions generator/src/typed/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ impl<'g> Tracker<'g> {
Positive, Negative,
CharRange, Str, Insens,
Rep, RepOnce, RepMin, RepMax, RepMinMax,
SOI, EOI,
SOI as soi,
EOI as eoi,
SOI as soi, EOI as eoi,
ANY as any,
PEEK as peek,
PeekSlice1, PeekSlice2,
Expand All @@ -159,16 +157,11 @@ impl<'g> Tracker<'g> {
PUSH as push,
POP as pop,
POP_ALL as pop_all,
ASCII_DIGIT as ascii_digit,
ASCII_NONZERO_DIGIT as ascii_nonzero_digit,
ASCII_BIN_DIGIT as ascii_bin_digit,
ASCII_OCT_DIGIT as ascii_oct_digit,
ASCII_HEX_DIGIT as ascii_hex_digit,
ASCII_ALPHA_LOWER as ascii_alpha_lower,
ASCII_ALPHA_UPPER as ascii_alpha_upper,
ASCII_ALPHA as ascii_alpha,
ASCII_ALPHANUMERIC as ascii_alphanumeric,
ASCII as ascii,
ascii_digit, ascii_nonzero_digit,
ascii_bin_digit, ascii_oct_digit,
ascii_hex_digit, ascii_alpha_lower,
ascii_alpha_upper, ascii_alpha,
ascii_alphanumeric, ascii,
NEWLINE as newline,
};
#(#seq)*
Expand Down
2 changes: 1 addition & 1 deletion generator/tests/dag/a.pest
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a = "a" ~ "a"?
~ = "~"*
~ = "~"*
2 changes: 1 addition & 1 deletion generator/tests/dag/b.pest
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
b = "b" ^ "b"?
^ = "^"+
^ = "^"+
2 changes: 1 addition & 1 deletion generator/tests/dag/c.pest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use a
use b
c = a::a ~ b::b
~ = " "? - c? - " "?
~ = " "? - c? - " "?
2 changes: 1 addition & 1 deletion generator/tests/dag/d.pest
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use a
use c
d = a::a - c::c
d = a::a - c::c
2 changes: 1 addition & 1 deletion generator/tests/dag/e.pest
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use b as _b
use c as c
e = a::a? - _b::b~* - c::c^+
~ = " "*
^ = ","
^ = ","
2 changes: 1 addition & 1 deletion generator/tests/dag/f.pest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use d
use e

f = d::d | e::e
f = d::d | e::e
7 changes: 2 additions & 5 deletions generator/tests/expected_import_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,8 @@ pub mod generics {
pub use pest3_core::sequence::Sequence2;
pub use pest3_core::typed::template::{
CharRange, Insens, Negative, PeekSlice1, PeekSlice2, Positive, Rep, RepMax, RepMin,
RepMinMax, RepOnce, Str, ANY as any, ASCII as ascii, ASCII_ALPHA as ascii_alpha,
ASCII_ALPHANUMERIC as ascii_alphanumeric, ASCII_ALPHA_LOWER as ascii_alpha_lower,
ASCII_ALPHA_UPPER as ascii_alpha_upper, ASCII_BIN_DIGIT as ascii_bin_digit,
ASCII_DIGIT as ascii_digit, ASCII_HEX_DIGIT as ascii_hex_digit,
ASCII_NONZERO_DIGIT as ascii_nonzero_digit, ASCII_OCT_DIGIT as ascii_oct_digit,
RepMinMax, RepOnce, Str, ANY as any, ascii, ascii_alpha, ascii_alphanumeric, ascii_alpha_lower,
ascii_alpha_upper, ascii_bin_digit, ascii_digit, ascii_hex_digit, ascii_nonzero_digit, ascii_oct_digit,
DROP as drop, EOI, EOI as eoi, NEWLINE as newline, PEEK as peek, PEEK_ALL as peek_all,
POP as pop, POP_ALL as pop_all, PUSH as push, SOI, SOI as soi,
};
Expand Down
Loading