Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephTLyons committed Nov 20, 2024
1 parent a7c8f53 commit 469f38b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/lenient_parse/internal/parser.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import gleam/bool
import gleam/io
import gleam/list
import gleam/option.{type Option, None, Some}
import gleam/queue.{type Queue}
Expand Down Expand Up @@ -234,7 +233,9 @@ fn parse_sign(

// TODO: Clean up the index range vs start and end index stuff here
// TODO: Delete {}s in case
// TODO: Clean up new_rest duplication
// TODO: Clean up new_rest duplicationBasePrefixOnly
// TODO: Get test to pass
// TODO: What kind of error should be reported
fn parse_base_prefix(
tokens tokens: List(Token),
index index: Int,
Expand All @@ -250,13 +251,16 @@ fn parse_base_prefix(
if { base == base_0 || base == base_2 }
&& { specifier == "b" || specifier == "B" }
-> {
io.debug("Here b")
let new_rest = case rest {
[] -> []
[_, ..rest] -> rest
}
Ok(ParseData(
data: Some(#(index_range, specifier, base_2)),
data: Some(#(
#(index_range.0, index_range.1 + 1),
"0" <> specifier,
base_2,
)),
next_index: end_index + 2,
tokens: new_rest,
))
Expand All @@ -269,9 +273,12 @@ fn parse_base_prefix(
[] -> []
[_, ..rest] -> rest
}
io.debug("Here o")
Ok(ParseData(
data: Some(#(index_range, specifier, base_8)),
data: Some(#(
#(index_range.0, index_range.1 + 1),
"0" <> specifier,
base_8,
)),
next_index: end_index + 2,
tokens: new_rest,
))
Expand All @@ -280,15 +287,14 @@ fn parse_base_prefix(
if { base == base_0 || base == base_16 }
&& { specifier == "x" || specifier == "X" }
-> {
io.debug("Here x")
let new_rest = case rest {
[] -> []
[_, ..rest] -> rest
}
Ok(ParseData(
data: Some(#(
#(index_range.0, index_range.1 + 1),
specifier,
"0" <> specifier,
base_16,
)),
next_index: end_index + 2,
Expand Down

0 comments on commit 469f38b

Please sign in to comment.