@@ -14,6 +14,9 @@ pub enum KeywordType {
1414 True ,
1515 False ,
1616 Null ,
17+ Print ,
18+ Read ,
19+ Flush ,
1720 Alloc ,
1821 AllocArray ,
1922 Int ,
@@ -38,6 +41,9 @@ impl KeywordType {
3841 Self :: True => "true" ,
3942 Self :: False => "false" ,
4043 Self :: Null => "null" ,
44+ Self :: Print => "print" ,
45+ Self :: Read => "read" ,
46+ Self :: Flush => "flush" ,
4147 Self :: Alloc => "alloc" ,
4248 Self :: AllocArray => "alloc_array" ,
4349 Self :: Int => "int" ,
@@ -62,6 +68,9 @@ impl KeywordType {
6268 "true" => Some ( Self :: True ) ,
6369 "false" => Some ( Self :: False ) ,
6470 "null" => Some ( Self :: Null ) ,
71+ "print" => Some ( Self :: Print ) ,
72+ "read" => Some ( Self :: Read ) ,
73+ "flush" => Some ( Self :: Flush ) ,
6574 "alloc" => Some ( Self :: Alloc ) ,
6675 "alloc_array" => Some ( Self :: AllocArray ) ,
6776 "int" => Some ( Self :: Int ) ,
@@ -83,6 +92,10 @@ impl KeywordType {
8392 pub fn is_type ( & self ) -> bool {
8493 matches ! ( self , Self :: Bool | Self :: Int )
8594 }
95+
96+ pub fn is_function ( & self ) -> bool {
97+ matches ! ( self , Self :: Flush | Self :: Read | Self :: Print )
98+ }
8699}
87100
88101#[ derive( Eq , Hash , Clone , Debug , PartialEq ) ]
@@ -296,6 +309,10 @@ impl Token {
296309 }
297310 }
298311
312+ pub fn is_function ( & self ) -> bool {
313+ matches ! ( self , Self :: Keyword ( _, keyword_type) if keyword_type. is_function( ) )
314+ }
315+
299316 pub fn is_assignment_operator ( & self ) -> bool {
300317 matches ! ( self , Self :: Operator ( _, operator) if operator. is_assignment_operator( ) )
301318 }
0 commit comments