// command parsing void use_rx_buffer(int bufptr) { char cmdbuf[UART_RX_BUFLEN]; int cmdlen = 0; int locbufptr = (bufptr-1)%UART_RX_BUFLEN; // find command begin while (uart_rx_buffer[locbufptr]!='\n') locbufptr=(locbufptr-1)&UART_RX_BUFMASK; locbufptr=(locbufptr+1)%UART_RX_BUFLEN; // copy command to the buffer (with \0 at the end) while (uart_rx_buffer[locbufptr]!='\n') {cmdbuf[cmdlen++]=uart_rx_buffer[locbufptr++]; locbufptr%=UART_RX_BUFLEN;} cmdbuf[cmdlen]='\0'; // test commands use_command(cmdbuf); }
ast_result_t pass_scope(ast_t** astp, pass_opt_t* options) { typecheck_t* t = &options->check; ast_t* ast = *astp; switch(ast_id(ast)) { case TK_USE: return use_command(ast, options); case TK_TYPE: case TK_INTERFACE: case TK_TRAIT: case TK_PRIMITIVE: case TK_CLASS: case TK_ACTOR: return scope_entity(t, ast); case TK_FFIDECL: if(!set_scope(t, t->frame->package, ast_child(ast), ast)) return AST_ERROR; break; case TK_PARAM: if(!set_scope(t, ast, ast_child(ast), ast)) return AST_ERROR; break; case TK_TYPEPARAM: if(!set_scope(t, ast, ast_child(ast), ast)) return AST_ERROR; break; case TK_LET: case TK_VAR: if(!scope_local(t, ast)) return AST_ERROR; break; default: {} } return AST_OK; }