[Lexer]
Separate the definition of foreign and builtin. Only a foreign function is now low level, a builtin function is simply builtin.
@@ -341,6 +341,20 @@ impl Attribute {
_=> panic!("unknown attribute type")
}
}
+
+ pub fn builtin(&self) -> Option<&str>{
+ match self {
+ Attribute::Foreign(_) => None,
+ Attribute::Builtin(name) => Some(name),
+ }
+ }
+ pub fn foreign(&self) -> Option<&str>{
+ match self {
+ Attribute::Foreign(name) => Some(name),
+ Attribute::Builtin(_) => None,
+ }
+ }
+
pub fn is_foreign(&self) -> bool{
match self
{
@@ -356,13 +370,6 @@ impl Attribute {
_ => false
}
}
-
- pub fn declares_a_low_level_func(&self) -> bool {
- match self {
- Attribute::Builtin(_) => true,
- Attribute::Foreign(_) => true,
- }
- }
}
impl<'a> Into<&'a str> for &'a Attribute {
@@ -432,6 +439,7 @@ impl fmt::Display for Keyword {
impl Keyword {
/// If the string is a keyword, return the associated token
/// else return None
+ /// XXX: Notice that because of the underscore, new keywords will not produce an err for this function
pub(crate) fn lookup_keyword(word: &str) -> Option<Token> {
match word {
"fn" => Some(Token::Keyword(Keyword::Fn)),
