Advertisement
Guest User

linux-gpib bison 2.6 patch

a guest
Aug 19th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. Index: lib/ibConfLex.l
  2. ===================================================================
  3. --- lib/ibConfLex.l (revision 1589)
  4. +++ lib/ibConfLex.l (working copy)
  5. @@ -7,8 +7,8 @@
  6.  
  7. %{
  8.  
  9. +#include "ib_internal.h"
  10. #include "ibConfYacc.h"
  11. -#include "ib_internal.h"
  12. #include <string.h>
  13.  
  14. %}
  15. Index: lib/ibConfYacc.y
  16. ===================================================================
  17. --- lib/ibConfYacc.y (revision 1589)
  18. +++ lib/ibConfYacc.y (working copy)
  19. @@ -1,3 +1,21 @@
  20. +%locations
  21. +%parse-param { void* yyscanner }
  22. +%parse-param { gpib_yyparse_private_t* parse_arg }
  23. +%lex-param { void* yyscanner }
  24. +%error-verbose
  25. +
  26. +%code requires{
  27. +typedef struct
  28. +{
  29. + ibConf_t *configs;
  30. + unsigned int configs_length;
  31. + unsigned int config_index;
  32. + ibBoard_t *boards;
  33. + unsigned int boards_length;
  34. + int board_index;
  35. +}gpib_yyparse_private_t;
  36. +}
  37. +
  38. %{
  39. #include <stdio.h>
  40. #include "ib_internal.h"
  41. @@ -8,23 +26,12 @@
  42. #include "ibConfYacc.h"
  43. #include "ibConfLex.h"
  44.  
  45. -#define YYERROR_VERBOSE
  46. -
  47. YY_DECL;
  48.  
  49. -#define YYPARSE_PARAM parse_arg
  50. -#define YYLEX_PARAM priv(YYPARSE_PARAM)->yyscanner
  51. -
  52. -typedef struct
  53. +void yyerror(YYLTYPE* yyloc, void* yyscanner, gpib_yyparse_private_t* parse_arg, const char *s)
  54. {
  55. - yyscan_t yyscanner;
  56. - ibConf_t *configs;
  57. - unsigned int configs_length;
  58. - unsigned int config_index;
  59. - ibBoard_t *boards;
  60. - unsigned int boards_length;
  61. - int board_index;
  62. -}gpib_yyparse_private_t;
  63. + fprintf(stderr, "%s\n", s);
  64. +}
  65.  
  66. static inline gpib_yyparse_private_t* priv( gpib_yyparse_private_t *parse_arg )
  67. {
  68. @@ -42,9 +49,9 @@
  69. return &parse_arg->boards[ parse_arg->board_index ];
  70. }
  71.  
  72. -void init_gpib_yyparse_private( gpib_yyparse_private_t *priv )
  73. +void init_gpib_yyparse_private( void** yyscanner, gpib_yyparse_private_t *priv )
  74. {
  75. - priv->yyscanner = 0;
  76. + *yyscanner = 0;
  77. priv->configs = NULL;
  78. priv->configs_length = 0;
  79. priv->config_index = 0;
  80. @@ -59,6 +66,7 @@
  81. FILE *infile;
  82. int retval = 0;
  83. int i;
  84. + void* yyscanner;
  85. gpib_yyparse_private_t priv;
  86.  
  87. if( ( infile = fopen( filename, "r" ) ) == NULL )
  88. @@ -69,7 +77,7 @@
  89. return -1;
  90. }
  91.  
  92. - init_gpib_yyparse_private( &priv );
  93. + init_gpib_yyparse_private( &yyscanner, &priv );
  94. priv.configs = configs;
  95. priv.configs_length = configs_length;
  96. priv.boards = boards;
  97. @@ -82,15 +90,15 @@
  98. {
  99. init_ibboard( &priv.boards[ i ] );
  100. }
  101. - gpib_yylex_init(&priv.yyscanner);
  102. - gpib_yyrestart(infile, priv.yyscanner);
  103. - if(gpib_yyparse(&priv))
  104. + gpib_yylex_init(&yyscanner);
  105. + gpib_yyrestart(infile, yyscanner);
  106. + if(gpib_yyparse(yyscanner, &priv))
  107. {
  108. fprintf(stderr, "libgpib: failed to parse configuration file\n");
  109. //XXX setIberr()
  110. retval = -1 ;
  111. }
  112. - gpib_yylex_destroy(priv.yyscanner);
  113. + gpib_yylex_destroy(yyscanner);
  114. fclose(infile);
  115.  
  116. if( retval == 0 )
  117. @@ -139,7 +147,7 @@
  118. | interface input
  119. | error
  120. {
  121. - fprintf(stderr, "input error on line %i of %s\n", gpib_yyget_lineno(priv(parse_arg)->yyscanner), DEFAULT_CONFIG_FILE);
  122. + fprintf(stderr, "input error on line %i of %s\n", gpib_yyget_lineno(yyscanner), DEFAULT_CONFIG_FILE);
  123. YYABORT;
  124. }
  125. ;
  126. @@ -257,10 +265,7 @@
  127.  
  128.  
  129.  
  130. -void yyerror(char *s)
  131. -{
  132. - fprintf(stderr, "%s\n", s);
  133. -}
  134.  
  135.  
  136.  
  137. +
  138. Index: lib/ib_internal.h
  139. ===================================================================
  140. --- lib/ib_internal.h (revision 1589)
  141. +++ lib/ib_internal.h (working copy)
  142. @@ -39,7 +39,6 @@
  143. int ibBoardOpen( ibBoard_t *board );
  144. int ibBoardClose( ibBoard_t *board );
  145. int ibGetNrBoards(void);
  146. -void yyerror(char *s);
  147. int iblcleos( const ibConf_t *conf );
  148. void ibPutMsg (char *format,...);
  149. void ibPutErrlog(int ud,char *routine);
  150. @@ -128,7 +127,6 @@
  151. }
  152.  
  153. #include <stdio.h>
  154. -int gpib_yyparse(void *parse_arg);
  155. int parse_gpib_conf( const char *filename, ibConf_t *configs,
  156. unsigned int configs_length, ibBoard_t *boards, unsigned int boards_length );
  157. #define YY_DECL int gpib_yylex(YYSTYPE *gpib_lvalp, YYLTYPE *gpib_llocp, yyscan_t yyscanner)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement