Open-source Languages & Tools for z/OS

 View Only
  • 1.  Newest m4 not working properly

    Posted 02-15-2018 11:45

    Having installed m4 1.4.18, build 001 my testcase for bison won’t run any longer.
    Running
    $ bison calc.y
    I get

    m4:/usr/local/ptz/share/bison/m4sugar/m4sugar.m4:1: ERROR: end of file in string
    divert(bison: subsidiary program `/usr/local/ptz/bin/m4’ failed (exit status 1)

    Do I use the previous m4, i.e. v1.4.15, build 0002 all is fine.



  • 2.  RE: Newest m4 not working properly

    Posted 02-16-2018 05:23

    Hello Manfred,
    Could you provide us your calc.y so we can properly reproduce and investigate your issue. Also what is your bash and bison versions?

    Thanks, Dan



  • 3.  RE: Newest m4 not working properly

    Posted 02-16-2018 09:00

    Hi Dan,
    bison is 2.3 build 0009 and bash is 4.2 build 0005. I think bash should have nothing to do with it as I can use those tools even from IBM’s /bin/sh.

    Here the calc.y

    /* Mini Calculator /
    /
    calc.y */

    %{
    #include "heading.h"
    int yyerror(char *s);
    int yylex(void);
    %}

    %union{
    int int_val;
    string* op_val;
    }

    %start input

    %token <int_val> INTEGER_LITERAL
    %type <int_val> exp
    %left PLUS
    %left MULT

    %%

    input: /* empty */
    | exp { cout << "Result: " << $1 << endl; }
    ;

    exp: INTEGER_LITERAL { $$ = $1; }
    | exp PLUS exp { $$ = $1 + $3; }
    | exp MULT exp { $$ = $1 * $3; }
    ;

    %%

    int yyerror(string s)
    {
    extern int yylineno; // defined and maintained in lex.c
    extern char *yytext; // defined and maintained in lex.c

    cerr << "ERROR: " << s << " at symbol “” << yytext;
    cerr << “” on line " << yylineno << endl;
    exit(1);
    }

    int yyerror(char *s)
    {
    return yyerror(string(s));
    }

    Thanks, Manfred



  • 4.  RE: Newest m4 not working properly

    Posted 02-16-2018 09:29

    FWIW: The forum software seems to have damaged the code. Try this:

    /* Mini Calculator /
    / calc.y */
    
    %{
    #include "heading.h"
    int yyerror(char *s);
    int yylex(void);
    %}
    
    %union{
      int     int_val;
      string* op_val;
    }
    
    %start  input
    
    %token  <int_val>       INTEGER_LITERAL
    %type   <int_val>       exp
    %left   PLUS
    %left   MULT
    
    %%
    
    input:  /* empty */
    | exp   { cout << "Result: " << $1 << endl; }
    ;
    
    exp:    INTEGER_LITERAL { $$ = $1; }
    | exp PLUS exp  { $$ = $1 + $3; }
    | exp MULT exp  { $$ = $1 * $3; }
    ;
    
    %%
    
    int yyerror(string s)
    {
      extern int yylineno;    // defined and maintained in lex.c
      extern char *yytext;    // defined and maintained in lex.c
      cerr << "ERROR: " << s << " at symbol "  << yytext;
      cerr << " on line " << yylineno << endl;
      exit(1);
    }
    
    int yyerror(char *s)
    {
      return yyerror(string(s));
    }


  • 5.  RE: Newest m4 not working properly

    Posted 11-07-2019 09:34

    I like to reactive things here.

    With bison 2.3 build 009 and either m4 1.4.15 build 0002 or m4 1.4.18 build b001:
    bison calc.y works fine

    With bison 3.04 build b002 and either m4 1.4.15 build 0002 or m4 1.4.18 build b001:
    bison calc.y gives an error:

    calc.y:1.1: error: syntax error, unexpected identifier
     a\@ԉ��@Á��������@aa@����K�@\al��������@�������K����@�������M����@\�]^���@�����M����]^l�l������@@���@@@@@���m���^@@������\@��m���^�l�����@@�����l�����@@L���m���n@@@@@@@�������m�������l����@@@L���m���n@@@@@@@���l����@@@����l����@@@����ll�����z@@a\@�����@\aO@���@@@�@����@LL@م����z@@LL@[�@LL@����^@�^���z@@@@�������m�������@�@[[@~@[�^@�O@���@����@���@@�@[[@~@[�@N@[�^@�O@���@����@���@@�@[[@~@[�@\@[�^@�^ll���@�������M������@�]�@@������@���@��������^@@@@aa@�������@���@����������@��@���K�@@������@����@\������^@@@@aa@�������@���@����������@��@���K�@@����@LL@�����z@@LL@�@LL@@��@������@@@LL@������^@@����@LL@@��@����@@LL@��������@LL@����^@@����M�]^����@�������M����@\�]�@@������@�������M������M�]]^�
     ^
    


  • 6.  RE: Newest m4 not working properly

    Posted 11-07-2019 09:40

    If I convert the gibberish to ascii I get

    /% `      ¨¨?¨  Ë`>È/∨ ¨¨?¨  Í>∨øÈ >È¨  /* Mini Calculator /
    C22C06990998CCC3C98C63C2C8CCC3C88C3CCFCCCCC8DCC3CDCDCC8822246662466676676722
    4F5460A161A01AAFAA0B0E8FC01AAFAC0DE1C8148100101E81311AE0FA0D9E9031C35C14F20F
    ...
    

    Any ideas?



  • 7.  RE: Newest m4 not working properly

    Posted 11-07-2019 10:14

    I forgot to remove the readable first line which looks gibberish when converted to ascii.