mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Parse and expand numeric bounds in canonicalization pass
This commit is contained in:
parent
17c5fe0bff
commit
a6f7579c07
113 changed files with 472 additions and 1361 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::annotation::{Formattable, Newlines, Parens};
|
||||
use crate::spaces::{fmt_comments_only, fmt_spaces, NewlineAt};
|
||||
use crate::Buf;
|
||||
use roc_parse::ast::{Base, NumericBound, Pattern};
|
||||
use roc_parse::ast::{Base, Pattern};
|
||||
|
||||
pub fn fmt_pattern<'a, 'buf>(
|
||||
buf: &mut Buf<'buf>,
|
||||
|
@ -32,7 +32,6 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
| Pattern::PrivateTag(_)
|
||||
| Pattern::Apply(_, _)
|
||||
| Pattern::NumLiteral(..)
|
||||
| Pattern::IntLiteral(..)
|
||||
| Pattern::NonBase10Literal { .. }
|
||||
| Pattern::FloatLiteral(..)
|
||||
| Pattern::StrLiteral(_)
|
||||
|
@ -117,25 +116,14 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
loc_pattern.format(buf, indent);
|
||||
}
|
||||
|
||||
&NumLiteral(string, bound) => {
|
||||
&NumLiteral(string) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string);
|
||||
if let NumericBound::Exact(width) = bound {
|
||||
buf.push_str(&width.to_string());
|
||||
}
|
||||
}
|
||||
&IntLiteral(string, bound) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string);
|
||||
if let NumericBound::Exact(width) = bound {
|
||||
buf.push_str(&width.to_string());
|
||||
}
|
||||
}
|
||||
&NonBase10Literal {
|
||||
base,
|
||||
string,
|
||||
is_negative,
|
||||
bound,
|
||||
} => {
|
||||
buf.indent(indent);
|
||||
if is_negative {
|
||||
|
@ -150,17 +138,10 @@ impl<'a> Formattable for Pattern<'a> {
|
|||
}
|
||||
|
||||
buf.push_str(string);
|
||||
|
||||
if let NumericBound::Exact(width) = bound {
|
||||
buf.push_str(&width.to_string());
|
||||
}
|
||||
}
|
||||
&FloatLiteral(string, bound) => {
|
||||
&FloatLiteral(string) => {
|
||||
buf.indent(indent);
|
||||
buf.push_str(string);
|
||||
if let NumericBound::Exact(width) = bound {
|
||||
buf.push_str(&width.to_string());
|
||||
}
|
||||
}
|
||||
StrLiteral(literal) => {
|
||||
todo!("Format string literal: {:?}", literal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue