Search the Community
Showing results for tags 'parser'.
-
Hello, many of you already know I'm working on a new programming language and I need some help to figure out an issue in the parser. I'm posting it here with the hope that someone knowledgeable enough can point out the solution and to also document this issue as I may forget the details if I don't make progress and set it aside. Here's the parser: /* * This file is part of EasyCodeIt. * * Copyright (C) 2021 TheDcoder <TheDcoder@protonmail.com> * * EasyCodeIt is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ %define parse.trace %code requires { #define _GNU_SOURCE /* Required to enable (v)asprintf */ #include <stdbool.h> #include "parser/tree.h" #include "parser/parser_internal.h" } %union { double num; struct { char *str; size_t len; } str; bool boolean; struct Expression expr; struct ExpressionList expr_list; } %token UNKNOWN %token WS %token NL '\n' %token COMMENT %token DIRECTIVE %token <num> NUMBER %token <str> STRING %token <boolean> BOOL %token <str> WORD %token <str> MACRO %token <str> VARIABLE %token OPERATOR %token BRACKET %token DOT %token COMMA /* Keywords */ %token K_DIM "Dim" %token K_LOCAL "Local" %token K_GLOBAL "Global" %token K_ENUM "Enum" %token K_CONST "Const" %token K_STATIC "Static" %token K_CONTINUE_CASE "ContinueCase" %token K_CONTINUE_LOOP "ContinueLoop" %token K_DEFAULT "Default" %token K_NULL "Null" %token K_DO "Do" %token K_UNTIL "Until" %token K_WHILE "While" %token K_END_WHILE "WEnd" %token K_FOR "For" %token K_IN "In" %token K_TO "To" %token K_STEP "Step" %token K_NEXT "Next" %token K_EXIT "Exit" %token K_EXITLOOP "ExitLoop" %token K_FUNC "Func" %token K_RETURN "Return" %token K_END_FUNC "EndFunc" %token K_IF "If" %token K_ELSE "Else" %token K_ELSE_IF "ElseIf" %token K_END_IF "EndIf" %token K_REDIM "ReDim" %token K_SELECT "Select" %token K_SWITCH "Switch" %token K_CASE "Case" %token K_END_SELECT "EndSelect" %token K_END_SWITCH "EndSwitch" /* Operators */ %precedence '?' %precedence ':' %left AND "And" OR "Or" %left LT '<' GT '>' LTE "<=" GTE ">=" EQU '=' NEQ "<>" SEQU "==" %left '&' %left '+' '-' %left '*' '/' %left '^' %left NOT "Not" %precedence INVERSION %precedence '.' /* WORKAROUND: Bison can't handle "sandwich" operators which surround the 2nd part of a binary expression */ %precedence '[' %precedence '(' %precedence GROUPING %type <expr> expression %type <expr_list> expression_list %{ int yylex(); void yyerror(const char *s); %} %% top: /* nothing */ | expression_list {print_expr($1.expression);} expression: BOOL {$$ = expr_from_prim(&(struct Primitive){.type = PRI_BOOLEAN, .boolean = $1});} | NUMBER {$$ = expr_from_prim(&(struct Primitive){.type = PRI_NUMBER, .number = $1});} | STRING {$$ = expr_from_str($1.str, $1.len);} | WORD {$$ = expr_from_ident($1.str, $1.len);} | MACRO {$$ = expr_from_ident($1.str, $1.len);} | VARIABLE {$$ = expr_from_ident($1.str, $1.len);} | expression '?' expression ':' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3, &$5}, 3, OP_CON);} | expression "And" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_AND);} | expression "Or" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_OR);} | expression '<' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_LT);} | expression '>' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_GT);} | expression '=' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_EQU);} | expression "<=" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_LTE);} | expression ">=" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_GTE);} | expression "<>" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_NEQ);} | expression "==" expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_SEQU);} | expression '&' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_CAT);} | expression '+' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_ADD);} | expression '-' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_SUB);} | expression '*' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_MUL);} | expression '/' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_DIV);} | expression '^' expression {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_EXP);} | "Not" expression {$$ = expr_from_expr((struct Expression *[]){&$2}, 1, OP_NOT);} | '-' expression %prec INVERSION {$$ = expr_from_expr((struct Expression *[]){&$2}, 1, OP_INV);} /*| expression '.' WORD {$$ = expr_from_expr((struct Expression *[]){&$1, &(struct Expression){expr_from_ident($3.str, $3.len)}}, 2, OP_ACC);}*/ | expression '.' WORD { struct Expression ident_expr = expr_from_ident($3.str, $3.len); $$ = expr_from_expr((struct Expression *[]){&$1, &ident_expr}, 2, OP_ACC); } | expression '[' expression ']' {$$ = expr_from_expr((struct Expression *[]){&$1, &$3}, 2, OP_ACC);} | expression '(' expression_list ')' {$$ = expr_from_call(&$1, &$3);} | expression '(' ')' {$$ = expr_from_call(&$1, NULL);} /* | expression '(' expression_list ')' %prec CALL {$$ = expr_from_call(&$1, &$3);} | expression '(' ')' %prec CALL {$$ = expr_from_call(&$1, NULL);} */ | '(' expression ')' %prec GROUPING {$$ = $2;} expression_list: /* expression {$$ = (struct ExpressionList){.expression = , .list = NULL};} | expression ',' expression_list {$$ = (struct ExpressionList){.expression = &$1, .list = &$3};} */ expression {$$ = exprlist_from_expr(&$1, NULL);} /* | expression ',' expression_list {$$ = exprlist_from_expr(&$1, &$3);} | expression '\n' expression_list {$$ = exprlist_from_expr(&$1, &$3);} */ | expression_list ',' expression {$$ = exprlist_from_expr(&$3, &$1);} | expression_list '\n' expression {$$ = exprlist_from_expr(&$3, &$1);} %% #include "parser/parser.c" And the "parser output" by Bison: Terminals unused in grammar UNKNOWN WS NL COMMENT DIRECTIVE OPERATOR BRACKET DOT COMMA "Dim" "Local" "Global" "Enum" "Const" "Static" "ContinueCase" "ContinueLoop" "Default" "Null" "Do" "Until" "While" "WEnd" "For" "In" "To" "Step" "Next" "Exit" "ExitLoop" "Func" "Return" "EndFunc" "If" "Else" "ElseIf" "EndIf" "ReDim" "Select" "Switch" "Case" "EndSelect" "EndSwitch" AND OR LT GT LTE GTE EQU NEQ SEQU NOT Grammar 0 $accept: top $end 1 top: ε 2 | expression_list 3 expression: BOOL 4 | NUMBER 5 | STRING 6 | WORD 7 | MACRO 8 | VARIABLE 9 | expression '?' expression ':' expression 10 | expression "And" expression 11 | expression "Or" expression 12 | expression '<' expression 13 | expression '>' expression 14 | expression '=' expression 15 | expression "<=" expression 16 | expression ">=" expression 17 | expression "<>" expression 18 | expression "==" expression 19 | expression '&' expression 20 | expression '+' expression 21 | expression '-' expression 22 | expression '*' expression 23 | expression '/' expression 24 | expression '^' expression 25 | "Not" expression 26 | '-' expression 27 | expression '.' WORD 28 | expression '[' expression ']' 29 | expression '(' expression_list ')' 30 | expression '(' ')' 31 | '(' expression ')' 32 expression_list: expression 33 | expression_list ',' expression 34 | expression_list '\n' expression Terminals, with rules where they appear $end (0) 0 '\n' (10) 34 '&' (38) 19 '(' (40) 29 30 31 ')' (41) 29 30 31 '*' (42) 22 '+' (43) 20 ',' (44) 33 '-' (45) 21 26 '.' (46) 27 '/' (47) 23 ':' (58) 9 '<' (60) 12 '=' (61) 14 '>' (62) 13 '?' (63) 9 '[' (91) 28 ']' (93) 28 '^' (94) 24 error (256) UNKNOWN (258) WS (259) NL (260) COMMENT (261) DIRECTIVE (262) NUMBER <num> (263) 4 STRING <str> (264) 5 BOOL <boolean> (265) 3 WORD <str> (266) 6 27 MACRO <str> (267) 7 VARIABLE <str> (268) 8 OPERATOR (269) BRACKET (270) DOT (271) COMMA (272) "Dim" (273) "Local" (274) "Global" (275) "Enum" (276) "Const" (277) "Static" (278) "ContinueCase" (279) "ContinueLoop" (280) "Default" (281) "Null" (282) "Do" (283) "Until" (284) "While" (285) "WEnd" (286) "For" (287) "In" (288) "To" (289) "Step" (290) "Next" (291) "Exit" (292) "ExitLoop" (293) "Func" (294) "Return" (295) "EndFunc" (296) "If" (297) "Else" (298) "ElseIf" (299) "EndIf" (300) "ReDim" (301) "Select" (302) "Switch" (303) "Case" (304) "EndSelect" (305) "EndSwitch" (306) AND (307) "And" (308) 10 OR (309) "Or" (310) 11 LT (311) GT (312) LTE (313) "<=" (314) 15 GTE (315) ">=" (316) 16 EQU (317) NEQ (318) "<>" (319) 17 SEQU (320) "==" (321) 18 NOT (322) "Not" (323) 25 INVERSION (324) GROUPING (325) Nonterminals, with rules where they appear $accept (89) on left: 0 top (90) on left: 1 2 on right: 0 expression <expr> (91) on left: 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 on right: 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 expression_list <expr_list> (92) on left: 32 33 34 on right: 2 29 33 34 State 0 0 $accept: • top $end NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 $default reduce using rule 1 (top) top go to state 10 expression go to state 11 expression_list go to state 12 State 1 4 expression: NUMBER • $default reduce using rule 4 (expression) State 2 5 expression: STRING • $default reduce using rule 5 (expression) State 3 3 expression: BOOL • $default reduce using rule 3 (expression) State 4 6 expression: WORD • $default reduce using rule 6 (expression) State 5 7 expression: MACRO • $default reduce using rule 7 (expression) State 6 8 expression: VARIABLE • $default reduce using rule 8 (expression) State 7 26 expression: '-' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 13 State 8 25 expression: "Not" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 14 State 9 31 expression: '(' • expression ')' NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 15 State 10 0 $accept: top • $end $end shift, and go to state 16 State 11 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' 32 expression_list: expression • '?' shift, and go to state 17 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 32 (expression_list) State 12 2 top: expression_list • 33 expression_list: expression_list • ',' expression 34 | expression_list • '\n' expression '\n' shift, and go to state 36 ',' shift, and go to state 37 $default reduce using rule 2 (top) State 13 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 26 | '-' expression • 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 26 (expression) State 14 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 25 | "Not" expression • 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 25 (expression) State 15 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' 31 | '(' expression • ')' '?' shift, and go to state 17 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 ')' shift, and go to state 38 State 16 0 $accept: top $end • $default accept State 17 9 expression: expression '?' • expression ':' expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 39 State 18 10 expression: expression "And" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 40 State 19 11 expression: expression "Or" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 41 State 20 12 expression: expression '<' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 42 State 21 13 expression: expression '>' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 43 State 22 15 expression: expression "<=" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 44 State 23 16 expression: expression ">=" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 45 State 24 14 expression: expression '=' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 46 State 25 17 expression: expression "<>" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 47 State 26 18 expression: expression "==" • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 48 State 27 19 expression: expression '&' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 49 State 28 20 expression: expression '+' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 50 State 29 21 expression: expression '-' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 51 State 30 22 expression: expression '*' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 52 State 31 23 expression: expression '/' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 53 State 32 24 expression: expression '^' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 54 State 33 27 expression: expression '.' • WORD WORD shift, and go to state 55 State 34 28 expression: expression '[' • expression ']' NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 56 State 35 29 expression: expression '(' • expression_list ')' 30 | expression '(' • ')' NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 ')' shift, and go to state 57 expression go to state 11 expression_list go to state 58 State 36 34 expression_list: expression_list '\n' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 59 State 37 33 expression_list: expression_list ',' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 60 State 38 31 expression: '(' expression ')' • $default reduce using rule 31 (expression) State 39 9 expression: expression • '?' expression ':' expression 9 | expression '?' expression • ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '?' shift, and go to state 17 ':' shift, and go to state 61 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 State 40 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 10 | expression "And" expression • 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 10 (expression) State 41 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 11 | expression "Or" expression • 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 11 (expression) State 42 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 12 | expression '<' expression • 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 12 (expression) State 43 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 13 | expression '>' expression • 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 13 (expression) State 44 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 15 | expression "<=" expression • 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 15 (expression) State 45 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 16 | expression ">=" expression • 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 16 (expression) State 46 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 14 | expression '=' expression • 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 14 (expression) State 47 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 17 | expression "<>" expression • 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 17 (expression) State 48 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 18 | expression "==" expression • 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 18 (expression) State 49 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 19 | expression '&' expression • 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 19 (expression) State 50 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 20 | expression '+' expression • 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 20 (expression) State 51 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 21 | expression '-' expression • 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 21 (expression) State 52 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 22 | expression '*' expression • 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 22 (expression) State 53 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 23 | expression '/' expression • 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 23 (expression) State 54 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 24 | expression '^' expression • 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 24 (expression) State 55 27 expression: expression '.' WORD • $default reduce using rule 27 (expression) State 56 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 28 | expression '[' expression • ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' '?' shift, and go to state 17 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 ']' shift, and go to state 62 State 57 30 expression: expression '(' ')' • $default reduce using rule 30 (expression) State 58 29 expression: expression '(' expression_list • ')' 33 expression_list: expression_list • ',' expression 34 | expression_list • '\n' expression '\n' shift, and go to state 36 ')' shift, and go to state 63 ',' shift, and go to state 37 State 59 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' 34 expression_list: expression_list '\n' expression • '?' shift, and go to state 17 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 34 (expression_list) State 60 9 expression: expression • '?' expression ':' expression 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' 33 expression_list: expression_list ',' expression • '?' shift, and go to state 17 "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 33 (expression_list) State 61 9 expression: expression '?' expression ':' • expression NUMBER shift, and go to state 1 STRING shift, and go to state 2 BOOL shift, and go to state 3 WORD shift, and go to state 4 MACRO shift, and go to state 5 VARIABLE shift, and go to state 6 '-' shift, and go to state 7 "Not" shift, and go to state 8 '(' shift, and go to state 9 expression go to state 64 State 62 28 expression: expression '[' expression ']' • $default reduce using rule 28 (expression) State 63 29 expression: expression '(' expression_list ')' • $default reduce using rule 29 (expression) State 64 9 expression: expression • '?' expression ':' expression 9 | expression '?' expression ':' expression • 10 | expression • "And" expression 11 | expression • "Or" expression 12 | expression • '<' expression 13 | expression • '>' expression 14 | expression • '=' expression 15 | expression • "<=" expression 16 | expression • ">=" expression 17 | expression • "<>" expression 18 | expression • "==" expression 19 | expression • '&' expression 20 | expression • '+' expression 21 | expression • '-' expression 22 | expression • '*' expression 23 | expression • '/' expression 24 | expression • '^' expression 27 | expression • '.' WORD 28 | expression • '[' expression ']' 29 | expression • '(' expression_list ')' 30 | expression • '(' ')' "And" shift, and go to state 18 "Or" shift, and go to state 19 '<' shift, and go to state 20 '>' shift, and go to state 21 "<=" shift, and go to state 22 ">=" shift, and go to state 23 '=' shift, and go to state 24 "<>" shift, and go to state 25 "==" shift, and go to state 26 '&' shift, and go to state 27 '+' shift, and go to state 28 '-' shift, and go to state 29 '*' shift, and go to state 30 '/' shift, and go to state 31 '^' shift, and go to state 32 '.' shift, and go to state 33 '[' shift, and go to state 34 '(' shift, and go to state 35 $default reduce using rule 9 (expression) And finally a minimal reproduction of the issue I'm facing: TheDcoder@arch /m/d/P/C/E/build (master)> eci 1\n2 Starting parse Entering state 0 Stack now 0 Reading a token Next token is token NUMBER () Shifting token NUMBER () Entering state 1 Stack now 0 1 Reducing stack by rule 4 (line 130): $1 = token NUMBER () -> $$ = nterm expression () Entering state 11 Stack now 0 11 Reading a token Next token is token NL () Reducing stack by rule 32 (line 168): $1 = nterm expression () -> $$ = nterm expression_list () Entering state 12 Stack now 0 12 Next token is token NL () Reducing stack by rule 2 (line 126): $1 = nterm expression_list () { "op": "No Operation", "args": [ 1.0 ] } -> $$ = nterm top () Entering state 10 Stack now 0 10 Next token is token NL () 2: syntax error at Error: popping nterm top () Stack now 0 Cleanup: discarding lookahead token NL () Stack now 0 Now I will explain the issue: I am trying to parse several different expressions and construct an "expression list" from them, however my parser immediately reduces the first expression to the "top" rule, but what I want is for it to make an "expression_list" which combines the following expression which is separated by a NL. This fact can be observed in the debug output from the reproduction script parse attempt, after the parser enters state 12 it immediately uses rule 2 to reduce to "top", but what we want is for it to use rule 34 and reduce to another "expression_list". The reason why I think this happens is because the reduction to top simply consumes less tokens and satisfies the parser, and as far as I can tell there is no way to force Bison to be "greedy" when reducing an "expression_list". So I'm unsure how to proceed further, I think we have to change the parser but I do not know how. I tried some silly things (like making another "super_top" non-terminal etc.) but those don't compile and produce a ton of conflicts 😕
-
Hi again guys!, i had COVID-19 for twice and i couldn't check the forum since 3 or 4 months ago till now! i hope you will get better if you're fighting for beat COVID-19 I have two question, first is about extracting all of the IP Address from an IP Ranges, for e.g: 192.168.1.1-192.255.255.255 (Start and End are variable and will be defined by the user) and for second one, i have a friend that he is Python programmer, he made a IP Parser that it can support large txt files (1TB) and it can parse all of them under 10min and it also supports low-end PCs that have 1 GB RAM! The list that his program parses are: #1765497 192.168.1.1 8082 #1765496 192.168.1.1 8084 #1965493 192.168.1.1 8089 #9565495 192.168.1.1 8086 #2565492 192.168.1.1 8081 and it converts very very fast to this: 192.168.1.1:8082 192.168.1.1:8084 192.168.1.1:8089 192.168.1.1:8086 192.168.1.1:8081 I wonder how to do this via AutoIt, if you can help me in this way, i will be happy✌❤ Thanks for your helps. FIRST_QUESTION_TEST.au3
-
Hello Sir, While searching for the solution to my problem, I have just gone through some of your old post. My name is Alok Arora Email id is *snip* I am writing a code to store logs for each script I run. This I did by using FileWriteLog function and it is successfully storing logs in txt file. Now, I have to work on to read the log file and if any script has been mistakenly clicked twice in a day script will pop up a message that task already done for the day by verifying entries in the log file. I have the logic for it.. I mean a variable will read the log file and will search for the entry and will perform action if entry found or not. I believe for reading the file I can write a code like $i =fileread("logfile.txt") Now I am stuck on how to compare the log entry in log file. Can you please help me in this?
-
-
- autoit
- implementation
-
(and 2 more)
Tagged with:
-
I'm writing a recursive decent parser in Autoit! The programming language i'm making is called HighLevel. I'm doing this for learning purposes, because it's fun and because I can implement it into my other project: Fullscreen Console With custom programming language! It's not easy... In Autoit you don't have objects like in Java or Visual Basic, so I had to figure out a way to still convert the code to an abstract syntax tree. I used nested array's and array based dictionary's instead of objects. The code is still very dirty and I need to make a lot of modifications but if you're careful with testing you'll see what it can do already. Console window Because this code eventually will get implemented into my console project I crafted a nice little console window (with a custom sci-fi looking theme, yeah i was a little bored haha). {ESC} is your panic button for now, it terminates the script completely. If you get an error while opening a script the text will turn red. To minimize it press the blue button, to close it use the red one, to drag the gui just grab it on one of the sides. The console window will display what you write to it with your "HighLevel-script" and some additional information: How to test it: Download: HighLevel.Au3, Debug.Au3 (includes a function to display nested arrays for debugging), GUI.bmp (for the console) Compile the Autoit code to EXE. The GUI.bmp must be in the same folder as the EXE file! Write a HighLevel-script (text file) and drag it into the compiled autoit-exe. The custom made little console window will pop up in the left top corner of your screen and your HighLevel-script (the text file) will be interpreted and executed. The Language: exit script: Abort show / hide the console: Show Hide write to/clear the console: Write 'this is a ''string''!' Clear variables: test_var_1 = 123 some_list = ['a', 5, true] some_list[1] = 3 math = 1 + 2 * 3 / 4 - -5 & test_var beep (under construction): Beep F, optD wait X seconds: Wait X Messages: Message 'Hello World!' move/click the mouse: Move X, Y Click send keys (under construction): Send 'HighLevel', True if's: If false ElseIf true # this part will run Else End subs: Sub X # do stuff End Call X for loops: For X = 1 to 10 # X iterates End Values: Input 'Give me input' Random YesNo 'yes or no' operators: + - * / & > = ! < ( ) And Not Or Example script: # my first HighLevel script message 'Hello World!' message 'Lets write to the console...' clear # clear the console... list = ['a', 16, true] for i = 0 to 2 write list[i] wait 1 end sub test if YesNo 'would you like to quit?' message 'Goodbye!' abort else write 1 + 2 * 3 & ' math!' end end call test test script.HighLevel GUI.bmp Debug.au3 HighLevel.au3
-
- interpreter
- parser
-
(and 3 more)
Tagged with:
-
Hello, first time poster here I am working on a project that has to parse a log file in real time. The thing is I know it's hard for Autoit to attach itself to log files when they're already in use by other programs, at least in my experience. I was taking a look at this thread because the log file is quite large and I think Autoit might be a little slow on it's own. The thing is I don't know how to use this properly to extract all data out of a log file or is there a native way to do this using Autoit. Basically , I just need a log parser that is able to read from a log that is 'already opened' and 'being written to' Thanks!
- 11 replies
-
Hi everyone Are there any people here that know how to use a parser generator that uses 'bnf' (not 'ebnf'!) i'm using the gold parser: http://goldparser.org/index.htm not possible in autoit: https://www.autoitscript.com/forum/topic/167663-activex-gold-parser-in-autoit-is-this-possible/ What i'm looking for is the best way to parse a list: <List> ::= <Item> ',' <List> | <Item> <Item> ::= Number | String for example, the tree returned from: 'test', 1, 2is: since its not possible in AutoIT code I did it in vb script. this is what i did: ' in the parse loop: Case Rule_List_Comma set result = new list call result.input(.tokens(0).data,.tokens(2).data) ' the list class: class list private arg0 private arg1 public sub input(a,b) set arg0 = a set arg1 = b end sub private sub push(item,byref stack) redim preserve stack(ubound(stack) + 1) stack(ubound(stack)) = item end sub public function value value = array(arg0.value) value2 = arg1.value if isarray(value2) then for each thing in value2 push thing,value next else push value2,value end if end function end class is there a better way to do this? regards, TheAutomator
-
hi everyone i have an interesting question about the gold parser: info: http://www.goldparser.org/index.htm download (regsvr32 to register): http://www.goldparser.org/engine/1/vb6/index.htm on the website it seems that this dll can be used as an activex object, does that mean that it can be used in autoit to? help for the activeX dll: http://www.goldparser.org/engine/1/vb6/doc/index.htm it gives me error code '4' if i try to use it... Const $gpMsgAccept = 3 Const $gpMsgCommentBlockRead = 9 Const $gpMsgCommentError = 7 Const $gpMsgCommentLineRead = 10 Const $gpMsgInternalError = 8 Const $gpMsgLexicalError = 5 Const $gpMsgNotLoadedError = 4 Const $gpMsgReduction = 2 Const $gpMsgSyntaxError = 6 Const $gpMsgTokenRead = 1 $Parser = ObjCreate("goldparserengine.goldparser") $Parser.LoadCompiledGrammar("test_script.cgt") $Parser.OpenFile("Program.txt") $Response = $Parser.Parse() MsgBox(0,'test',$Response) If there are people interested in answering or helping feel free to reply and then i will upload the "test_script.cgt" somewhere if you want i know this question is a bit specific but you never know.. Thanks for reading! TheAutomator.
-
Hello, try to read simple XML and i decided to make generic script. I've a value (140403_0_21_00_XX_C044C021_00N_00F) and i MUST retrieve a value in same node id (="21") <PubPlain> <spread0 id="1" pdfname="140403_0_01_54_MN_M048C001_00N_00F" /> <spread1 id="2" pdfname="140403_0_02_00_XX_C002C047_00N_00F" /> <spread2 id="3" pdfname="140403_0_03_54_XX_CL16C003_00N_00F" /> <spread3 id="4" pdfname="140403_0_04_54_XX_C004CL15_00N_00F" /> <spread4 id="5" pdfname="140403_0_05_54_XX_ML14M005_00N_00F" /> <spread5 id="6" pdfname="140403_0_06_54_XX_C006CL13_00N_00F" /> <spread6 id="7" pdfname="140403_0_07_54_XX_CL12C007_00N_00F" /> <spread7 id="8" pdfname="140403_0_08_54_XX_C008CL11_00N_00F" /> <spread8 id="9" pdfname="140403_0_09_54_XX_CL10C009_00N_00F" /> <spread9 id="10" pdfname="140403_0_10_54_XX_M010CL09_00N_00F" /> <spread10 id="11" pdfname="140403_0_11_54_XX_CL08C011_00N_00F" /> <spread11 id="12" pdfname="140403_0_12_54_XX_C012CL07_00N_00F" /> <spread12 id="13" pdfname="140403_0_13_54_XX_CL06C013_00N_00F" /> <spread13 id="14" pdfname="140403_0_14_54_XX_C014CL05_00N_00F" /> <spread14 id="15" pdfname="140403_0_15_54_XX_CL04C015_00N_00F" /> <spread15 id="16" pdfname="140403_0_16_54_XX_C016CL03_00N_00F" /> <spread16 id="17" pdfname="140403_0_17_54_XX_CL02C017_00N_00F" /> <spread17 id="18" pdfname="140403_0_18_54_XX_C018CL01_00N_00F" /> <spread18 id="19" pdfname="140403_0_19_00_XX_C046C019_00N_00F" /> <spread19 id="20" pdfname="140403_0_20_00_XX_C020C045_00N_00F" /> <spread20 id="21" pdfname="140403_0_21_00_XX_C044C021_00N_00F" /> <spread21 id="22" pdfname="140403_0_22_00_XX_M022C043_00N_00F" /> <spread22 id="23" pdfname="140403_0_23_00_XX_C042C023_00N_00F" /> <spread23 id="24" pdfname="140403_0_24_00_XX_C024C041_00N_00F" /> <spread24 id="25" pdfname="140403_0_25_00_XX_M040C025_00N_00F" /> <spread25 id="26" pdfname="140403_0_26_00_XX_C026C039_00N_00F" /> <spread26 id="27" pdfname="140403_0_27_00_XX_C038C027_00N_00F" /> <spread27 id="28" pdfname="140403_0_28_00_XX_C028C037_00N_00F" /> <spread28 id="29" pdfname="140403_0_29_00_XX_C036C029_00N_00F" /> <spread29 id="30" pdfname="140403_0_30_00_XX_C030C035_00N_00F" /> <spread30 id="31" pdfname="140403_0_31_00_XX_M034C031_00N_00F" /> <spread31 id="32" pdfname="140403_0_32_00_XX_C032C033_00N_00F" /> </PubPlain> My XMLs are simple but tend to vary in certain conditions. So i haven't any sure foothold, I must read XML everytime. I've read several approaches to XML reading but can't determine which best. (dead?) _XMLDomWrapper.au3 seems to be the best choice; can you suggest best way to implement XML reading in AI ? Thank you, m.
-
Hi, I'm inviting all autoit forum members to contribute to a HTML parser udf. I going to attempt to replicate a python module called BeautifulSoup. It would be greatly appreciated if some senior Autoit programmers took interest in this topic. There is no template other than the module written in python located here and the documentation here. I can't wait to see what this develops into.
-
For those of you (and I know from previous discussions that there are people out there) making your own compilers and interpreters and choosing not to use tools like yacc. Pratt's parser is a predictive parser, but with a number of improvements that make it so easy to implement you wonder why in the 38 since the original paper was published it hasn't been used in more than a small handful of projects. Look it up if you ever consider hand writing a parser. I managed to write a calculator from first principles in 30 mins. 20 minutes of that was writing the lexer. Mat Edit: Just to give you an idea of how unused this is... Google "Pratt's Parser" and you'll get this thread as the first result.
- 12 replies