ragel.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright 2001-2007 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 _RAGEL_H
  21. #define _RAGEL_H
  22. #include <stdio.h>
  23. #include <iostream>
  24. #include <fstream>
  25. #include <string>
  26. #include "vector.h"
  27. #include "config.h"
  28. #include "common.h"
  29. #define PROGNAME "ragel"
  30. /* Target output style. */
  31. enum CodeStyle
  32. {
  33. GenTables,
  34. GenFTables,
  35. GenFlat,
  36. GenFFlat,
  37. GenGoto,
  38. GenFGoto,
  39. GenIpGoto,
  40. GenSplit
  41. };
  42. /* To what degree are machine minimized. */
  43. enum MinimizeLevel {
  44. MinimizeApprox,
  45. MinimizeStable,
  46. MinimizePartition1,
  47. MinimizePartition2
  48. };
  49. enum MinimizeOpt {
  50. MinimizeNone,
  51. MinimizeEnd,
  52. MinimizeMostOps,
  53. MinimizeEveryOp
  54. };
  55. /* Target implementation */
  56. enum RubyImplEnum
  57. {
  58. MRI,
  59. Rubinius
  60. };
  61. /* Options. */
  62. extern MinimizeLevel minimizeLevel;
  63. extern MinimizeOpt minimizeOpt;
  64. extern const char *machineSpec, *machineName;
  65. extern bool printStatistics;
  66. extern bool wantDupsRemoved;
  67. extern bool generateDot;
  68. extern bool generateXML;
  69. extern RubyImplEnum rubyImpl;
  70. /* Error reporting format. */
  71. enum ErrorFormat {
  72. ErrorFormatGNU,
  73. ErrorFormatMSVC,
  74. };
  75. extern ErrorFormat errorFormat;
  76. extern int gblErrorCount;
  77. extern char mainMachine[];
  78. InputLoc makeInputLoc( const char *fileName, int line = 0, int col = 0 );
  79. std::ostream &operator<<( std::ostream &out, const InputLoc &loc );
  80. /* Error reporting. */
  81. std::ostream &error();
  82. std::ostream &error( const InputLoc &loc );
  83. std::ostream &warning( const InputLoc &loc );
  84. struct XmlParser;
  85. void xmlEscapeHost( std::ostream &out, char *data, long len );
  86. extern CodeStyle codeStyle;
  87. /* IO filenames and stream. */
  88. extern bool displayPrintables;
  89. extern int gblErrorCount;
  90. /* Options. */
  91. extern int numSplitPartitions;
  92. extern bool noLineDirectives;
  93. std::ostream &error();
  94. /* Target language and output style. */
  95. extern CodeStyle codeStyle;
  96. extern int numSplitPartitions;
  97. extern bool noLineDirectives;
  98. #endif