Skip to content

Commit

Permalink
Fixing lexer documentation to not make incorrect formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
fosdickio committed Feb 14, 2024
1 parent 03c1044 commit ee34b30
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
13 changes: 10 additions & 3 deletions base/src/expressions/lexer/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use super::Lexer;
use super::{ParsedRange, ParsedReference, Result};

impl Lexer {
// Consumes a reference in A1 style like:
// AS23, $AS23, AS$23, $AS$23, R12
// Or returns an error
/// Consumes a reference in A1 style like:
/// AS23, $AS23, AS$23, $AS$23, R12
/// Or returns an error
fn consume_reference_a1(&mut self) -> Result<ParsedReference> {
let mut absolute_column = false;
let mut absolute_row = false;
Expand Down Expand Up @@ -70,6 +70,9 @@ impl Lexer {
// row -> '$' row_name | row_name
// column_name -> 'A'..'XFD'
// row_name -> 1..1_048_576
//
/// Consumes a range of references in A1 style like:
/// AS23:AS24, $AS23:AS24, AS$23:AS24, $AS$23:AS24, R12:R23, $R12:R23, R$12:R23, $R$12:R23
pub(super) fn consume_range_a1(&mut self) -> Result<ParsedRange> {
// first let's try to parse a cell
let mut position = self.position;
Expand Down Expand Up @@ -203,6 +206,8 @@ impl Lexer {
}
}

/// Consumes a range of references in R1C1 style like:
/// R12C3:R23C4, R[2]C[-2]:R[3]C[6], R3C[6]:R[-3]C4, R[-2]C:R[-2]C
pub(super) fn consume_range_r1c1(&mut self) -> Result<ParsedRange> {
// first let's try to parse a cell
match self.consume_reference_r1c1() {
Expand Down Expand Up @@ -230,6 +235,8 @@ impl Lexer {
}
}

/// Consumes a reference in R1C1 style like:
/// R12C3, R[2]C[-2], R3C[6], R[-3]C4, RC1, R[-2]C
pub(super) fn consume_reference_r1c1(&mut self) -> Result<ParsedReference> {
// R12C3, R[2]C[-2], R3C[6], R[-3]C4, RC1, R[-2]C
let absolute_column;
Expand Down
36 changes: 18 additions & 18 deletions base/src/expressions/lexer/structured_references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ impl Lexer {
.replace("''", "'"))
}

// Possibilities:
// 1. MyTable[#Totals] or MyTable[#This Row]
// 2. MyTable[MyColumn]
// 3. MyTable[[My Column]]
// 4. MyTable[[#This Row], [My Column]]
// 5. MyTable[[#Totals], [MyColumn]]
// 6. MyTable[[#This Row], [Jan]:[Dec]]
// 7. MyTable[]
//
// Multiple specifiers are not supported yet:
// 1. MyTable[[#Data], [#Totals], [MyColumn]]
//
// In particular note that names of columns are escaped only when they are in the first argument
// We use '[' and ']'
// When there is only a specifier but not a reference the specifier is not in brackets
//
// Invalid:
// * MyTable[#Totals, [Jan]:[March]] => MyTable[[#Totals], [Jan]:[March]]
/// Possibilities:
/// 1. MyTable[#Totals] or MyTable[#This Row]
/// 2. MyTable[MyColumn]
/// 3. MyTable[[My Column]]
/// 4. MyTable[[#This Row], [My Column]]
/// 5. MyTable[[#Totals], [MyColumn]]
/// 6. MyTable[[#This Row], [Jan]:[Dec]]
/// 7. MyTable[]
///
/// Multiple specifiers are not supported yet:
/// 1. MyTable[[#Data], [#Totals], [MyColumn]]
///
/// In particular note that names of columns are escaped only when they are in the first argument
/// We use '[' and ']'
/// When there is only a specifier but not a reference the specifier is not in brackets
///
/// Invalid:
/// * MyTable[#Totals, [Jan]:[March]] => MyTable[[#Totals], [Jan]:[March]]
//
// NOTES:
// * MyTable[[#Totals]] is translated into MyTable[#Totals]
Expand Down

0 comments on commit ee34b30

Please sign in to comment.