fn parse_global_scalar_declaration(
        &mut self,
        data_type: DataType,
        ident: Token,
    ) -> Result<(), Box<dyn Error>> {
        // TODO: Allow assignation of initial value during declaration

        if data_type == DataType::VOID {
            return Err("Unable to declare variables with void type.".into());
        }

        self.global_symbol_table.add_symbol(
            ident.lexeme,
            data_type,
            0,
            SymType::VARIABLE,
            0,
            SymClass::GLOBAL,
        );

        match &self.current_token {
            Some(token) => {
                match token.token_type {
                    TokenType::SEMI => {
                        self.consume()?;
                    }
                    TokenType::COMMA => {
                        // If there are more declarations to parse, keep going
                        self.consume()?;
                        let ident_tok = self.match_token(TokenType::IDENT)?;
                        self.parse_global_scalar_declaration(data_type, ident_tok)?;
                    }
                    _ => return Err("Missing ',' or ';' after declaration".into()),
                }
            }
            None => return Err("Missing ',' or ';' after declaration".into()),
        }

        Ok(())
    }
// We require these parameters as these tokens should have
// been scanned prior to invocation of this function
We require these parameters as these tokens should have
been scanned prior to invocation of this function
We require these parameters as these tokens should have been scanned prior to invocation of this function
fn parse_global_scalar_declaration(
        &mut self,
        data_type: DataType,
        ident: Token,
    ) -> Result<(), Box<dyn Error>> {
        // TODO: Allow assignation of initial value during declaration
        if data_type == DataType::VOID {
            return Err("Unable to declare variables with void type.".into());
        }
        self.global_symbol_table.add_symbol(
            ident.lexeme,
            data_type,
            0,
            SymType::VARIABLE,
            0,
            SymClass::GLOBAL,
        );
        match &self.current_token {
            Some(token) => {
                match token.token_type {
                    TokenType::SEMI => {
                        self.consume()?;
                    }
                    TokenType::COMMA => {
                        // If there are more declarations to parse, keep going
                        self.consume()?;
                        let ident_tok = self.match_token(TokenType::IDENT)?;
                        self.parse_global_scalar_declaration(data_type, ident_tok)?;
                    }
                    _ => return Err("Missing ',' or ';' after declaration".into()),
                }
            }
            None => return Err("Missing ',' or ';' after declaration".into()),
        }
        Ok(())
    }
fn parse_global_scalar_declaration ( & mut self , data_type : DataType , ident : Token , ) -> Result < ( ) , Box < dyn Error > > { // TODO: Allow assignation of initial value during declaration if data_type == DataType :: VOID { return Err ( " " . into ( ) ) ; } self . global_symbol_table . add_symbol ( ident . lexeme , data_type , 0 , SymType :: VARIABLE , 0 , SymClass :: GLOBAL , ) ; match & self . current_token { Some ( token ) => { match token . token_type { TokenType :: SEMI => { self . consume ( ) ? ; } TokenType :: COMMA => { // If there are more declarations to parse, keep going self . consume ( ) ? ; let ident_tok = self . match_token ( TokenType :: IDENT ) ? ; self . parse_global_scalar_declaration ( data_type , ident_tok ) ? ; } _ => return Err ( " " . into ( ) ) , } } None => return Err ( " " . into ( ) ) , } Ok ( ( ) ) }
We require these parameters as these tokens should have
been scanned prior to invocation of this function
We require these parameters as these tokens should have been scanned prior to invocation of this function
&mut self
data_type
DataType
ident
Token