-
Notifications
You must be signed in to change notification settings - Fork 56
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
DATE, DATE_AND_TIME, TIME, TIME_OF_DAY #173
Conversation
added Date-lexer token added LiteralDate AST-element added Date-datatype which internally is an i64 LiteralDates generate i64 literals
added DateAndTime-lexer token added LiteralDateAndTime AST-element added DateAndTime-datatype which internally is an i64 LiteralDateAndTime generate i64 literals
added LiteralTime-lexer token added LiteralTime AST-element added TIME-datatype which internally is an i64 (ms) LiteralTime generates i64 literals
added LiteralTimeOfDay-lexer token added LiteralTimeOfDay AST-element added TIME_OF_DAY-datatype which internally is an DATE_AND_TIME fixed to 1970-01-01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump version in cargo.toml to 0.2
hour, | ||
min, | ||
sec, | ||
milli, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add nano precision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} => self.llvm.create_const_int( | ||
self.index, | ||
&Some(self.llvm.i64_type().into()), | ||
format!("{}", calculate_time_micro(*day, *hour, *min, *sec, *milli)).as_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nano
src/lexer.rs
Outdated
#[regex("(TIME_OF_DAY|TOD)#\\d+:\\d+:\\d+(.\\d+)?")] | ||
LiteralTimeOfDay, | ||
|
||
#[regex("(T(IME)?|t(ime)?)#(\\d+(.\\d+)?(d|h|ms|m|s))+")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove case insensitivity ... either go all in or nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/lexer/tests/lexer_tests.rs
Outdated
@@ -264,6 +264,56 @@ fn real_literals_test() { | |||
lexer.advance(); | |||
} | |||
|
|||
#[test] | |||
fn date_literals_test() { | |||
let mut lexer = lex("DATE#1984-10-01 D#1-1-1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add more rainy day tests (e.g only 2 segments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
let location = lexer.location(); | ||
//get rid of D# or DATE# | ||
let slice = slice_and_advance(lexer); | ||
let hash_location = slice.find('#').unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also go with unwrap()
add comment why it is safe to call unwrap
src/parser/expressions_parser.rs
Outdated
hour, | ||
min, | ||
sec, | ||
milli: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fraction of seconds allowed
add tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/parser/expressions_parser.rs
Outdated
let mut chars = slice.char_indices(); | ||
let mut curr = chars.next(); | ||
|
||
let mut values = [0.0f64, 0.0, 0.0, 0.0, 0.0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimize (remove writes-array)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
#[test] | ||
fn literal_time_test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tests for negative time
add tests for fractions
add tests for ns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
let lexer = super::lex( | ||
" | ||
PROGRAM exp | ||
t#; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upper case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/typesystem.rs
Outdated
} | ||
} | ||
|
||
/// Create the DATE_AND_TIME's DataType description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add documentation to book
i bumped the version now! ... it was the very first comment ... lol |
supports datatypes, literals
lets discuss how we really should represent the values internally