daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WHITE_SPACE [ \t\v\f]
  2.  
  3. CHARS [./_-:]
  4. %{
  5. #include <stdio.h>
  6. #include <stdlib.h>          
  7. #include <string.h>
  8. #include "myscanner.tab.h"
  9. static void out();
  10. static void comment();
  11. int counter=1;
  12. char buff[10000][10000];
  13. int yylex();
  14.  
  15. %}
  16.  
  17. %%
  18. "<ss:Workbook>" {out(); yylval.string = strdup(yytext);return WORKBOOK_START;}
  19. "</ss:Workbook>" {out(); yylval.string = strdup(yytext);return WORKBOOK_END;}
  20. "<ss:Styles>" {out(); yylval.string = strdup(yytext);return STYLES_START;}
  21. "</ss:Styles>" {out(); yylval.string = strdup(yytext);return STYLES_END;}
  22. "<ss:Style" {out(); yylval.string = strdup(yytext);return STYLE_START;}
  23. "</ss:Style>" {out(); yylval.string = strdup(yytext);return STYLE_END;}
  24. "<ss:Worksheet" {out(); yylval.string = strdup(yytext);return WORKSHEET_START;}
  25. "</ss:Worksheet>" {out(); yylval.string = strdup(yytext);return WORKSHEET_END;}
  26. "<ss:Table" {out(); yylval.string = strdup(yytext);return TABLE_START;}
  27. "</ss:Table>" {out(); yylval.string = strdup(yytext);return TABLE_END;}
  28. "<ss:Column" {out(); yylval.string = strdup(yytext);return COLUMN_START;}
  29. "<ss:Row" {out(); yylval.string = strdup(yytext);return ROW_START;}
  30. "</ss:Row>" {out(); yylval.string = strdup(yytext);return ROW_END;}
  31. "<ss:Cell" {out(); yylval.string = strdup(yytext);return CELL_START;}
  32. "</ss:Cell>" {out(); yylval.string = strdup(yytext);return CELL_END;}
  33. "<ss:Data" {out(); yylval.string = strdup(yytext);return DATA_START;}
  34. "</ss:Data>" {out(); yylval.string = strdup(yytext);return DATA_END;}
  35. "ss:ID" {out(); yylval.string = strdup(yytext);return ID;}
  36. "ss:Name" {out(); yylval.string = strdup(yytext);return NAME;}
  37. "ss:Protected" {out(); yylval.string = strdup(yytext);return PROTECTED;}
  38. "ss:ExpandedColumnCount" {out(); yylval.string = strdup(yytext);return EXPCOLCOUNT;}
  39. "ss:ExpandedRowCount" {out(); yylval.string = strdup(yytext);return EXPROWCOUNT;}
  40. "ss:StyleID" {out(); yylval.string = strdup(yytext);return STYLEID;}
  41. "ss:Hidden" {out(); yylval.string = strdup(yytext);return HIDDEN;}
  42. "ss:Widthbgcc" {out(); yylval.string = strdup(yytext);return WIDTH;}
  43. "ss:Height" {out(); yylval.string = strdup(yytext);return HEIGHT;}
  44. "ss:MergeAcross" {out(); yylval.string = strdup(yytext);return MERGEACR;}
  45. "ss:MergeDown" {out(); yylval.string = strdup(yytext);return MERGEDOWN;}
  46. "ss:Type" {out(); yylval.string = strdup(yytext);return TYPE;}
  47. "true"  {out(); yylval.boolean = strdup(yytext);return BOOLEAN;}
  48. "false"  {out(); yylval.boolean = strdup(yytext);return BOOLEAN;}
  49. "=" {out(); yylval.string = strdup(yytext);return EQUAL;}
  50. ">" {out(); yylval.string = strdup(yytext);return CLOSE_TAG;}
  51. "/>" {out(); yylval.string = strdup(yytext);return COL_END_TAG;}
  52. \" {out(); yylval.string = strdup(yytext);return QUOTES;}
  53. [0-9]+ {out(); yylval.integer = strdup(yytext); return INTEGER; }
  54. [a-zA-Z0-9]+ {out(); yylval.string = strdup(yytext);return STRING;}
  55. "Number" {out(); yylval.string = strdup(yytext);return MY_NUMBER;}
  56. "Boolean" {out(); yylval.string = strdup(yytext);return MY_BOOL;}
  57. "String" {out(); yylval.string = strdup(yytext);return MY_STRING;}
  58. "DateTime" {out(); yylval.string = strdup(yytext);return MY_DATETIME;}
  59. "!--" {out(); comment();}
  60.  
  61. "\n"   {out(); counter++;}
  62. {WHITE_SPACE}+ {out();}
  63. .       {}
  64.  
  65.  
  66. %%
  67.  
  68.  
  69. static void out()
  70. {
  71.     ECHO;
  72.     strcat(buff[counter],yytext);
  73. }
  74.  
  75. static void comment()
  76. {
  77.     //input() : reads the next character from the input stream
  78.     int c;
  79.     while ((c = input()) != 0)
  80.     {
  81.         if (c == "--")
  82.         {
  83.             while ((c = input()) == "--")
  84.             ;
  85.             if (c == '>')
  86.                 return;
  87.             if (c == 0)
  88.                 break;
  89.         }
  90.     }
  91.     yyerror("Invalid comment");
  92. }
  93.  
  94. int main(int argc, char** argv)
  95. {
  96.     ++argv;
  97.     --argc;
  98.  
  99.     if ( argc > 0 )
  100.         yyin = fopen(argv[0], "r"); // Read from file
  101.     else
  102.         yyin = stdin; // Read from stdin
  103.  
  104.  
  105.     yyout = fopen ("output", "w"); // Output file
  106.    
  107.     yyparse();
  108.    
  109.     return 0;
  110. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top