Skip to content

Commit c8c397a

Browse files
committed
Minor fixes
1 parent 16e8f83 commit c8c397a

File tree

8 files changed

+1655
-1539
lines changed

8 files changed

+1655
-1539
lines changed

src/ast.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,13 @@ statement_t *newStatement(int type, void *content) {
465465
statement_t *stmt = ast_emalloc(sizeof(statement_t));
466466
stmt->entity = type;
467467
stmt->next = NULL;
468-
stmt->line = yylinenor;
468+
stmt->line = yylinenor - 1;
469469

470470
stmt->file[0] = 0;
471471
if (ParsedFile != NULL) {
472472
snprintf(stmt->file, sizeof(stmt->file), "%s", ParsedFile);
473+
} else {
474+
snprintf(stmt->file, sizeof(stmt->file), "%s", "stdin");
473475
}
474476

475477
switch (type) {

src/eval.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ int evaluate_condition(ifCondition_t *cond, EXPRESSION_PARAMS()) {
499499
walkB = walkB->next;
500500
}
501501
*ax = res;
502+
} else {
503+
*ax = 0;
502504
}
503505
break;
504506
}
@@ -1025,9 +1027,7 @@ void evaluate_expression(expr_t *expr, EXPRESSION_PARAMS()) {
10251027
if (!stop) {
10261028
fprintf(stderr, "%s.%d Failed to find ID: '%s'\n", ((statement_t *)stmt)->file,
10271029
((statement_t *)stmt)->line, expr->id.id);
1028-
if (!*interactive) {
1029-
exit(1);
1030-
}
1030+
exit(1);
10311031
}
10321032

10331033
break;

src/gram.y

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ logical_a:
349349

350350
logical_b:
351351
logical_b '&' '&' _ logical_expression {
352-
$$ = newExpr_Logical($1, $5, NULL);
352+
$$ = newExpr_Logical($5, $1, NULL);
353353
}
354354
| logical_expression {
355355
$$ = $1;
@@ -592,22 +592,22 @@ body:
592592
};
593593

594594
vector:
595-
'[' arguments_list ']' {
596-
argsList_t *args = (argsList_t*) $2;
595+
'[' _ arguments_list _ ']' {
596+
argsList_t *args = (argsList_t*) $3;
597597
$$ = newExpr_Vector(args);
598598
}
599599
|
600-
'[' forEachStatement ']' {
601-
statement_t* stmt = newStatement(LANG_ENTITY_FOREACH, $2);
600+
'[' _ forEachStatement _ ']' {
601+
statement_t* stmt = newStatement(LANG_ENTITY_FOREACH, $3);
602602
$$ = newExpr_VectorFromForEach(stmt);
603603
}
604-
| '[' ']' {
604+
| '[' _ ']' {
605605
$$ = newExpr_Vector(NULL);
606606
};
607607

608608
arguments_list:
609-
arguments_list ',' expressions {
610-
expr_t *expr = $3;
609+
arguments_list _ ',' _ expressions {
610+
expr_t *expr = $5;
611611
$$ = newArgument(expr, $1);
612612
}
613613
| expressions {
@@ -936,8 +936,6 @@ void initParser() {
936936
void runInteractive(int argc, char *argv[], interactiveInterpreterFunc func, int stacksize, int heapsize, const char *prompt) {
937937
char lineBuffer[256];
938938
939-
ParsedFile = "stdin";
940-
941939
memset(lineBuffer, 0, sizeof(lineBuffer));
942940
943941
PRINT_INTERACTIVE_BANNER();
@@ -969,7 +967,6 @@ void runInteractive(int argc, char *argv[], interactiveInterpreterFunc func, int
969967
970968
void runCommand(int argc, char *argv[], interactiveInterpreterFunc func, char *command, int stacksize, int heapsize) {
971969
YY_BUFFER_STATE buffer;
972-
ParsedFile = "stdin";
973970
974971
/* Parse from provided command line */
975972
buffer = yy_scan_string(command);

src/interpret.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ void interpret_statements_interactive(int argc, char *argv[], statement_t *stmt,
13381338

13391339
if (e->type == EXPR_TYPE_FUNCCALL) {
13401340
functionCall_t *call = e->func;
1341-
evaluate_expression(call->id, NULL, NULL, PROVIDE_CONTEXT_INIT(), NULL, NULL);
1341+
evaluate_expression(call->id, stmt, NULL, PROVIDE_CONTEXT_INIT(), NULL, NULL);
13421342

13431343
POP_VAL(&stv, &sp, &sc);
13441344
if (stv.type == LIBFUNCPTRTYPE) {

src/lex.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "y.tab.h"
77

8-
int yylinenor=0;
8+
int yylinenor=1;
99

1010
int return_spaces = 0;
1111
int double_citation = 0;

src/lex.yy.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#line 2 "lex.yy.c"
2+
#line 3 "lex.yy.c"
33

44
#define YY_INT_ALIGNED short int
55

@@ -46,7 +46,6 @@ typedef int16_t flex_int16_t;
4646
typedef uint16_t flex_uint16_t;
4747
typedef int32_t flex_int32_t;
4848
typedef uint32_t flex_uint32_t;
49-
typedef uint64_t flex_uint64_t;
5049
#else
5150
typedef signed char flex_int8_t;
5251
typedef short int flex_int16_t;
@@ -155,7 +154,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
155154
typedef size_t yy_size_t;
156155
#endif
157156

158-
extern yy_size_t yyleng;
157+
extern int yyleng;
159158

160159
extern FILE *yyin, *yyout;
161160

@@ -198,7 +197,7 @@ struct yy_buffer_state
198197
/* Number of characters read into yy_ch_buf, not including EOB
199198
* characters.
200199
*/
201-
yy_size_t yy_n_chars;
200+
int yy_n_chars;
202201

203202
/* Whether we "own" the buffer - i.e., we know we created it,
204203
* and can realloc() it to grow it, and should free() it to
@@ -267,8 +266,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
267266

268267
/* yy_hold_char holds the character lost when yytext is formed. */
269268
static char yy_hold_char;
270-
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
271-
yy_size_t yyleng;
269+
static int yy_n_chars; /* number of characters read into yy_ch_buf */
270+
int yyleng;
272271

273272
/* Points to current character in buffer. */
274273
static char *yy_c_buf_p = NULL;
@@ -295,7 +294,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
295294

296295
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
297296
YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
298-
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len );
297+
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
299298

300299
void *yyalloc ( yy_size_t );
301300
void *yyrealloc ( void *, yy_size_t );
@@ -351,7 +350,7 @@ static void yynoreturn yy_fatal_error ( const char* msg );
351350
*/
352351
#define YY_DO_BEFORE_ACTION \
353352
(yytext_ptr) = yy_bp; \
354-
yyleng = (yy_size_t) (yy_cp - yy_bp); \
353+
yyleng = (int) (yy_cp - yy_bp); \
355354
(yy_hold_char) = *yy_cp; \
356355
*yy_cp = '\0'; \
357356
(yy_c_buf_p) = yy_cp;
@@ -462,7 +461,7 @@ char *yytext;
462461

463462
#include "y.tab.h"
464463

465-
int yylinenor=0;
464+
int yylinenor=1;
466465

467466
int return_spaces = 0;
468467
int double_citation = 0;
@@ -510,7 +509,7 @@ FILE *yyget_out ( void );
510509

511510
void yyset_out ( FILE * _out_str );
512511

513-
yy_size_t yyget_leng ( void );
512+
int yyget_leng ( void );
514513

515514
char *yyget_text ( void );
516515

@@ -579,7 +578,7 @@ static int input ( void );
579578
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
580579
{ \
581580
int c = '*'; \
582-
yy_size_t n; \
581+
int n; \
583582
for ( n = 0; n < max_size && \
584583
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
585584
buf[n] = (char) c; \
@@ -1051,7 +1050,7 @@ static int yy_get_next_buffer (void)
10511050

10521051
else
10531052
{
1054-
yy_size_t num_to_read =
1053+
int num_to_read =
10551054
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
10561055

10571056
while ( num_to_read <= 0 )
@@ -1065,7 +1064,7 @@ static int yy_get_next_buffer (void)
10651064

10661065
if ( b->yy_is_our_buffer )
10671066
{
1068-
yy_size_t new_size = b->yy_buf_size * 2;
1067+
int new_size = b->yy_buf_size * 2;
10691068

10701069
if ( new_size <= 0 )
10711070
b->yy_buf_size += b->yy_buf_size / 8;
@@ -1123,7 +1122,7 @@ static int yy_get_next_buffer (void)
11231122

11241123
if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
11251124
/* Extend the array by 50%, plus the number we really need. */
1126-
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1125+
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
11271126
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
11281127
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
11291128
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
@@ -1212,7 +1211,7 @@ static int yy_get_next_buffer (void)
12121211
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
12131212
{ /* need to shift things up to make room */
12141213
/* +2 for EOB chars. */
1215-
yy_size_t number_to_move = (yy_n_chars) + 2;
1214+
int number_to_move = (yy_n_chars) + 2;
12161215
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
12171216
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
12181217
char *source =
@@ -1263,7 +1262,7 @@ static int yy_get_next_buffer (void)
12631262

12641263
else
12651264
{ /* need more input */
1266-
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1265+
int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
12671266
++(yy_c_buf_p);
12681267

12691268
switch ( yy_get_next_buffer( ) )
@@ -1632,12 +1631,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr )
16321631
*
16331632
* @return the newly allocated buffer state object.
16341633
*/
1635-
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len )
1634+
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
16361635
{
16371636
YY_BUFFER_STATE b;
16381637
char *buf;
16391638
yy_size_t n;
1640-
yy_size_t i;
1639+
int i;
16411640

16421641
/* Get memory for full buffer, including space for trailing EOB's. */
16431642
n = (yy_size_t) (_yybytes_len + 2);
@@ -1679,7 +1678,7 @@ static void yynoreturn yy_fatal_error (const char* msg )
16791678
do \
16801679
{ \
16811680
/* Undo effects of setting up yytext. */ \
1682-
yy_size_t yyless_macro_arg = (n); \
1681+
int yyless_macro_arg = (n); \
16831682
YY_LESS_LINENO(yyless_macro_arg);\
16841683
yytext[yyleng] = (yy_hold_char); \
16851684
(yy_c_buf_p) = yytext + yyless_macro_arg; \
@@ -1719,7 +1718,7 @@ FILE *yyget_out (void)
17191718
/** Get the length of the current token.
17201719
*
17211720
*/
1722-
yy_size_t yyget_leng (void)
1721+
int yyget_leng (void)
17231722
{
17241723
return yyleng;
17251724
}

0 commit comments

Comments
 (0)