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

DATE, DATE_AND_TIME, TIME, TIME_OF_DAY #173

Merged
merged 8 commits into from
May 7, 2021
Merged

DATE, DATE_AND_TIME, TIME, TIME_OF_DAY #173

merged 8 commits into from
May 7, 2021

Conversation

riederm
Copy link
Collaborator

@riederm riederm commented May 1, 2021

supports datatypes, literals
lets discuss how we really should represent the values internally

riederm and others added 7 commits April 27, 2021 19:43
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
@riederm riederm requested a review from ghaith May 1, 2021 19:45
Copy link
Collaborator Author

@riederm riederm left a 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,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add nano precision

Copy link
Collaborator Author

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(),
Copy link
Collaborator Author

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))+")]
Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -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");
Copy link
Collaborator Author

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)

Copy link
Collaborator Author

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();
Copy link
Collaborator Author

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

hour,
min,
sec,
milli: 0,
Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

let mut chars = slice.char_indices();
let mut curr = chars.next();

let mut values = [0.0f64, 0.0, 0.0, 0.0, 0.0];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

optimize (remove writes-array)

Copy link
Collaborator Author

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() {
Copy link
Collaborator Author

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

Copy link
Collaborator Author

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#;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

upper case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

}
}

/// Create the DATE_AND_TIME's DataType description
Copy link
Collaborator Author

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

@riederm
Copy link
Collaborator Author

riederm commented May 6, 2021

i bumped the version now! ... it was the very first comment ... lol

@ghaith ghaith merged commit 5d2da7c into master May 7, 2021
@ghaith ghaith deleted the DATE branch May 7, 2021 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants