Skip to content

Commit

Permalink
parsing function parameters successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
rigel-star committed Sep 17, 2024
1 parent 491872a commit 75fa8c8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions examples/input1.bic
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def extern calc_sum_till(x: integer) -> integer;
def extern print_name(name: str) -> integer;
def extern print_int(x: integer) -> void;

def main() -> void {
let a: integer = 300;
let b: integer = calc_sum_till(a);
print_int(b);
let a: str = "Manish";
let b = print_name(a);
print_int();
}
2 changes: 1 addition & 1 deletion src/code_gen/aarch64/aarch64_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'aarch64> CodeGen for Aarch64CodeGen<'aarch64> {
}

fn gen_local_var_decl_stmt(&mut self, var_decl_stmt: &crate::ast::VarDeclStmt, expr_ast: &Expr) {
let symbol = if let Some(ctx_rc) = &self.ctx {
let symbol: Symbol = if let Some(ctx_rc) = &self.ctx {
let ctx_borrow = ctx_rc.borrow_mut();
if let Some(symbol) = ctx_borrow.sym_table.get_symbol(var_decl_stmt.symtbl_pos) {
symbol.clone()
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl<'parser> Parser<'parser> {
TokenKind::KW_CHAR => LitTypeVariant::U8,
TokenKind::KW_STR => LitTypeVariant::Str,
TokenKind::KW_LONG => LitTypeVariant::I64,
_ => panic!("Cannot parse a type of {:?}", current_tok),
_ => panic!("{:?} is not a valid datatype.", current_tok),
}
}

Expand Down
4 changes: 4 additions & 0 deletions syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@
<div class="prod-rule">
<b>&lt;func-decl&gt;</b> &colon;&equals; <span class="keyword">def</span> &lpar;&lt;<span class="keyword">extern</span>&gt; &lt;name&gt;&lpar;&lt;parameter-list&gt;&rpar;&apos;&semi;&apos;&rpar; &vert; &lpar;&lt;name&gt;&lpar;&lt;parameter-list&gt;&rpar; &lt;compound-statement&gt;&rpar;
</div>

<div>
Native Interface is named BicharaNI
</div>
</body>
</html>

0 comments on commit 75fa8c8

Please sign in to comment.