inputdata.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2008 Adrian Thurston <thurston@complang.org>
  3. */
  4. /* This file is part of Ragel.
  5. *
  6. * Ragel is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Ragel is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Ragel; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef _INPUT_DATA
  21. #define _INPUT_DATA
  22. #include "gendata.h"
  23. #include <iostream>
  24. #include <sstream>
  25. struct Parser;
  26. struct ParseData;
  27. struct InputItem
  28. {
  29. enum Type {
  30. HostData,
  31. Write,
  32. };
  33. Type type;
  34. std::ostringstream data;
  35. std::string name;
  36. ParseData *pd;
  37. Vector<char *> writeArgs;
  38. InputLoc loc;
  39. InputItem *prev, *next;
  40. };
  41. struct Parser;
  42. typedef AvlMap<const char*, Parser*, CmpStr> ParserDict;
  43. typedef AvlMapEl<const char*, Parser*> ParserDictEl;
  44. typedef DList<Parser> ParserList;
  45. typedef DList<InputItem> InputItemList;
  46. typedef Vector<const char *> ArgsVector;
  47. struct InputData
  48. {
  49. InputData() :
  50. inputFileName(0),
  51. outputFileName(0),
  52. inStream(0),
  53. outStream(0),
  54. outFilter(0),
  55. dotGenParser(0)
  56. {}
  57. /* The name of the root section, this does not change during an include. */
  58. const char *inputFileName;
  59. const char *outputFileName;
  60. /* Io globals. */
  61. std::istream *inStream;
  62. std::ostream *outStream;
  63. output_filter *outFilter;
  64. Parser *dotGenParser;
  65. ParserDict parserDict;
  66. ParserList parserList;
  67. InputItemList inputItems;
  68. ArgsVector includePaths;
  69. void verifyWritesHaveData();
  70. void writeOutput();
  71. void makeOutputStream();
  72. void openOutput();
  73. void generateReduced();
  74. void prepareMachineGen();
  75. void terminateAllParsers();
  76. void cdDefaultFileName( const char *inputFile );
  77. void goDefaultFileName( const char *inputFile );
  78. void javaDefaultFileName( const char *inputFile );
  79. void rubyDefaultFileName( const char *inputFile );
  80. void csharpDefaultFileName( const char *inputFile );
  81. void ocamlDefaultFileName( const char *inputFile );
  82. void writeLanguage( std::ostream &out );
  83. void writeXML( std::ostream &out );
  84. };
  85. #endif