@@ -388,7 +388,7 @@ bool ps_parse_factor(ps_compiler *compiler, ps_ast_block *block, ps_ast_node **e
388388 PARSE_BEGIN ("FACTOR" , "" );
389389
390390 ps_value factor_value = {.type = & ps_system_none , .data .v = NULL };
391- ps_token_type unary_operator ;
391+ ps_token_type unary_operator = PS_TOKEN_NONE ;
392392
393393 switch (lexer -> current_token .type )
394394 {
@@ -458,8 +458,8 @@ bool ps_parse_factor(ps_compiler *compiler, ps_ast_block *block, ps_ast_node **e
458458 ps_ast_node * * operand = NULL ;
459459 if (!ps_parse_factor (compiler , block , operand ))
460460 TRACE_ERROR ("UNARY" );
461- ps_operator_unary unary_operator = ps_operator_unary_from_token (lexer -> current_token . type );
462- * expression = (ps_ast_node * )ps_ast_create_unary_operation (start_line , start_column , unary_operator , * operand );
461+ ps_operator_unary operator_unary = ps_operator_unary_from_token (unary_operator );
462+ * expression = (ps_ast_node * )ps_ast_create_unary_operation (start_line , start_column , operator_unary , * operand );
463463 if (* expression == NULL )
464464 RETURN_ERROR (PS_ERROR_OUT_OF_MEMORY )
465465 PARSE_END ("OK UNARY" )
@@ -477,13 +477,14 @@ bool ps_parse_factor(ps_compiler *compiler, ps_ast_block *block, ps_ast_node **e
477477 PARSE_END ("OK" )
478478}
479479
480- bool ps_parse_function_call_random (ps_compiler * compiler , ps_ast_block * block , ps_ast_node * * expression , int * arg_count ,
481- ps_ast_node * * arg1 )
480+ bool ps_parse_function_call_random (ps_compiler * compiler , ps_ast_block * block , int * n_args , ps_ast_node * * arg )
482481{
483482 PARSE_BEGIN ("FUNCTION_CALL" , "RANDOM" );
483+ (void )start_line ;
484+ (void )start_column ;
484485
485486 // Random function can be called with 3 signatures:
486- // 1. Random or Random() => Real from 0.0 to 1.0 excluded
487+ // 1. Random or Random() => Real from 0.0 (included) to 1.0 ( excluded)
487488 // 2. Random(Integer) => Integer
488489 // 3. Random(Unsigned) => Unsigned
489490 if (lexer -> current_token .type == PS_TOKEN_LEFT_PARENTHESIS )
@@ -492,25 +493,25 @@ bool ps_parse_function_call_random(ps_compiler *compiler, ps_ast_block *block, p
492493 READ_NEXT_TOKEN
493494 if (lexer -> current_token .type == PS_TOKEN_RIGHT_PARENTHESIS )
494495 {
495- * arg_count = 0 ;
496+ * n_args = 0 ;
496497 // factor.type = &ps_system_real;
497498 READ_NEXT_TOKEN
498499 }
499500 else
500501 {
501- * arg_count = 1 ;
502- if (!ps_parse_expression (compiler , block , arg1 ))
502+ * n_args = 1 ;
503+ if (!ps_parse_expression (compiler , block , arg ))
503504 TRACE_ERROR ("PARAMETER" );
504- // if (arg1 ->type != &ps_system_integer && arg1 ->type != &ps_system_unsigned)
505+ // if (arg ->type != &ps_system_integer && arg ->type != &ps_system_unsigned)
505506 // RETURN_ERROR(PS_ERROR_UNEXPECTED_TYPE);
506507 EXPECT_TOKEN (PS_TOKEN_RIGHT_PARENTHESIS );
507- // factor.type = arg1 ->type;
508+ // factor.type = arg ->type;
508509 READ_NEXT_TOKEN
509510 }
510511 }
511512 else
512513 {
513- * arg_count = 0 ;
514+ * n_args = 0 ;
514515 // factor.type = &ps_system_real;
515516 }
516517
@@ -520,14 +521,17 @@ bool ps_parse_function_call_random(ps_compiler *compiler, ps_ast_block *block, p
520521bool ps_parse_function_call_low_high (ps_compiler * compiler , ps_ast_block * block , ps_symbol * * symbol )
521522{
522523 PARSE_BEGIN ("FUNCTION_CALL" , "LOW_HIGH" )
524+ (void )start_line ;
525+ (void )start_column ;
526+
527+ ps_identifier identifier = {0 };
523528
524529 // Low and High functions have one "symbolic" argument, i.e. Low(Days) or High(Day)
525530 EXPECT_TOKEN (PS_TOKEN_LEFT_PARENTHESIS )
526531 READ_NEXT_TOKEN
527532 if (lexer -> current_token .type != PS_TOKEN_IDENTIFIER && lexer -> current_token .type != PS_TOKEN_INTEGER &&
528533 lexer -> current_token .type != PS_TOKEN_UNSIGNED && lexer -> current_token .type != PS_TOKEN_CHAR )
529534 RETURN_ERROR (PS_ERROR_UNEXPECTED_TOKEN )
530- ps_identifier identifier = {0 };
531535 COPY_IDENTIFIER (identifier )
532536 * symbol = ps_compiler_find_symbol (compiler , block , identifier , false);
533537 if (* symbol == NULL )
@@ -539,22 +543,24 @@ bool ps_parse_function_call_low_high(ps_compiler *compiler, ps_ast_block *block,
539543 PARSE_END ("OK ")
540544}
541545
542- bool ps_parse_function_call_power (ps_compiler * compiler , ps_ast_block * block , ps_value * arg1 , ps_value * arg2 )
546+ bool ps_parse_function_call_power (ps_compiler * compiler , ps_ast_block * block , ps_ast_node * * arg1 , ps_ast_node * * arg2 )
543547{
544548 PARSE_BEGIN ("FUNCTION_CALL" , "POWER" );
549+ (void )start_line ;
550+ (void )start_column ;
545551
546552 EXPECT_TOKEN (PS_TOKEN_LEFT_PARENTHESIS )
547553 READ_NEXT_TOKEN
548554 if (!ps_parse_expression (compiler , block , arg1 ))
549555 TRACE_ERROR ("ARG1" )
550- if (!ps_value_is_number (arg1 ) && !ps_value_is_real (arg1 ))
551- RETURN_ERROR (PS_ERROR_EXPECTED_NUMBER )
556+ // if (!ps_value_is_number(arg1) && !ps_value_is_real(arg1))
557+ // RETURN_ERROR(PS_ERROR_EXPECTED_NUMBER)
552558 EXPECT_TOKEN (PS_TOKEN_COMMA )
553559 READ_NEXT_TOKEN
554560 if (!ps_parse_expression (compiler , block , arg2 ))
555561 TRACE_ERROR ("ARG2" )
556- if (!ps_value_is_number (arg2 ) && !ps_value_is_real (arg2 ))
557- RETURN_ERROR (PS_ERROR_EXPECTED_NUMBER )
562+ // if (!ps_value_is_number(arg2) && !ps_value_is_real(arg2))
563+ // RETURN_ERROR(PS_ERROR_EXPECTED_NUMBER)
558564 EXPECT_TOKEN (PS_TOKEN_RIGHT_PARENTHESIS )
559565 READ_NEXT_TOKEN
560566
@@ -576,11 +582,8 @@ bool ps_parse_function_call_system(ps_compiler *compiler, ps_ast_block *block, p
576582
577583 if (function == & ps_system_function_random )
578584 {
579- ps_ast_node * expression = NULL ;
580- if (!ps_parse_function_call_random (compiler , block , & expression , & n_args , & expression ))
585+ if (!ps_parse_function_call_random (compiler , block , & n_args , & args [0 ]))
581586 TRACE_ERROR ("RANDOM" )
582- if (n_args == 1 )
583- args [0 ] = expression ;
584587 }
585588 else if (function == & ps_system_function_get_tick_count )
586589 {
0 commit comments