├── AUTHORS ├── COPYING ├── ChangeLog ├── Doxyfile ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── configure ├── configure.ac ├── doxygen-html ├── FlexLexer_8h.html ├── FlexLexer_8h_source.html ├── annotated.html ├── classCNAdd-members.html ├── classCNAdd.html ├── classCNAdd.png ├── classCNConstant-members.html ├── classCNConstant.html ├── classCNConstant.png ├── classCNDivide-members.html ├── classCNDivide.html ├── classCNDivide.png ├── classCNModulo-members.html ├── classCNModulo.html ├── classCNModulo.png ├── classCNMultiply-members.html ├── classCNMultiply.html ├── classCNMultiply.png ├── classCNNegate-members.html ├── classCNNegate.html ├── classCNNegate.png ├── classCNPower-members.html ├── classCNPower.html ├── classCNPower.png ├── classCNSubtract-members.html ├── classCNSubtract.html ├── classCNSubtract.png ├── classCalcContext-members.html ├── classCalcContext.html ├── classCalcNode-members.html ├── classCalcNode.html ├── classCalcNode.png ├── classExampleFlexLexer-members.html ├── classExampleFlexLexer.html ├── classExampleFlexLexer.png ├── classFlexLexer-members.html ├── classFlexLexer.html ├── classFlexLexer.png ├── classes.html ├── classexample_1_1Driver-members.html ├── classexample_1_1Driver.html ├── classexample_1_1Parser-members.html ├── classexample_1_1Parser.html ├── classexample_1_1Scanner-members.html ├── classexample_1_1Scanner.html ├── classexample_1_1Scanner.png ├── classexample_1_1location-members.html ├── classexample_1_1location.html ├── classexample_1_1position-members.html ├── classexample_1_1position.html ├── classexample_1_1slice-members.html ├── classexample_1_1slice.html ├── classexample_1_1stack-members.html ├── classexample_1_1stack.html ├── doxygen.css ├── doxygen.png ├── driver_8cc.html ├── driver_8cc_source.html ├── driver_8h.html ├── driver_8h_source.html ├── expression_8h.html ├── expression_8h_source.html ├── exprtest_8cc.html ├── exprtest_8cc_source.html ├── files.html ├── functions.html ├── functions_0x63.html ├── functions_0x64.html ├── functions_0x65.html ├── functions_0x66.html ├── functions_0x67.html ├── functions_0x68.html ├── functions_0x69.html ├── functions_0x6c.html ├── functions_0x6e.html ├── functions_0x6f.html ├── functions_0x70.html ├── functions_0x72.html ├── functions_0x73.html ├── functions_0x74.html ├── functions_0x76.html ├── functions_0x79.html ├── functions_0x7e.html ├── functions_enum.html ├── functions_eval.html ├── functions_func.html ├── functions_type.html ├── functions_vars.html ├── globals.html ├── globals_defs.html ├── globals_func.html ├── globals_type.html ├── globals_vars.html ├── hierarchy.html ├── index.html ├── location_8hh.html ├── location_8hh_source.html ├── namespaceexample.html ├── namespacemembers.html ├── namespacemembers_func.html ├── namespaces.html ├── parser_8cc.html ├── parser_8cc_source.html ├── parser_8h.html ├── parser_8h_source.html ├── parser_8yy.html ├── parser_8yy_source.html ├── position_8hh.html ├── position_8hh_source.html ├── readme_8dox.html ├── scanner_8cc.html ├── scanner_8cc_source.html ├── scanner_8h.html ├── scanner_8h_source.html ├── scanner_8ll.html ├── scanner_8ll_source.html ├── stack_8hh.html ├── stack_8hh_source.html ├── structexample_1_1Parser_1_1token-members.html ├── structexample_1_1Parser_1_1token.html ├── structyy__buffer__state-members.html ├── structyy__buffer__state.html ├── structyy__trans__info-members.html ├── structyy__trans__info.html ├── tab_b.gif ├── tab_l.gif ├── tab_r.gif ├── tabs.css ├── unionexample_1_1Parser_1_1semantic__type-members.html ├── unionexample_1_1Parser_1_1semantic__type.html ├── y_8tab_8h.html └── y_8tab_8h_source.html ├── doxygen.css ├── flex-bison-cpp-example.sln ├── scripts ├── depcomp ├── install-sh ├── missing └── ylwrap └── src ├── FlexLexer.h ├── Makefile.am ├── Makefile.in ├── Makefile.plain ├── driver.cc ├── driver.h ├── expression.h ├── exprtest.cc ├── exprtest.txt ├── exprtest.vcproj ├── libexampleparser.vcproj ├── location.hh ├── parser.cc ├── parser.h ├── parser.yy ├── position.hh ├── readme.dox ├── scanner.cc ├── scanner.h ├── scanner.ll ├── stack.hh └── y.tab.h /AUTHORS: -------------------------------------------------------------------------------- 1 | Timo Bingmann 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 14 rue de Plaisance, 75014 Paris, France 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-09-05 Timo Bingmann 2 | 3 | * Two small fix-up lines to get it working with bison-2.4.1. Added 4 | one standard header include and making CalcNode a opaque class 5 | pointer in %union due to changed include file order. 6 | 7 | * Correcting associativity of the power operator: right. 8 | 9 | 2008-10-23 Timo Bingmann 10 | 11 | * FlexLexer.h, scanner.ll: Corrected a very subtle bug with the 12 | newly introduced virtual yywrap() function in the FlexLexer 13 | class. Depending on how the header was included, the class 14 | contained the virtual yywrap() function or not. These differing 15 | class declarations lead to very strange NULL pointer exceptions, 16 | because the different compiled objects assume different class 17 | memory layouts. Ultimately the exprtest program always segfaulted. 18 | 19 | 2008-08-03 Timo Bingmann 20 | 21 | * scanner.ll, y.tab.h: Fixing compilation problem which was 22 | reported to happen when no %union directive is used: in this case 23 | the include headers order is changed around by bison and breaks 24 | compilation. This was fixed by never including parser.h directly, 25 | but always using scanner.h. 26 | 27 | * FlexLexer.h: updated file to work with new flex version 28 | 2.5.35. The new version adds a virtual function yywrap() to the 29 | yyFlexLexer class. This function is automatically defined in any 30 | lexer source file generated by flex. However because I copied 31 | FlexLexer.h from an older flex distribution, the function 32 | definition throws a "no member function" compiler error. 33 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | SUBDIRS = src 4 | 5 | EXTRA_DIST = Doxyfile doxygen.css doxygen-html/* \ 6 | flex-bison-cpp-example.sln 7 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/NEWS -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | AC_PREREQ(2.59) 4 | 5 | AC_INIT([flex-bison-cpp-example], [0.1.4]) 6 | AC_CONFIG_SRCDIR([src/exprtest.cc]) 7 | AC_CONFIG_AUX_DIR([scripts]) 8 | 9 | AM_INIT_AUTOMAKE 10 | AM_MAINTAINER_MODE 11 | 12 | if test "$CFLAGS" == ""; then 13 | CFLAGS="-g -I/usr/include" 14 | fi 15 | if test "$CXXFLAGS" == ""; then 16 | CXXFLAGS="-g -I/usr/include" 17 | fi 18 | 19 | # enable full optimization by configure switch 20 | AC_ARG_ENABLE(optimize, 21 | AS_HELP_STRING([--enable-optimize], 22 | [Build with full optimization @<:@default=no@:>@]), 23 | [ case "${enableval}" in 24 | yes) 25 | CFLAGS="$CFLAGS -O3 -DNDEBUG"; 26 | CXXFLAGS="$CXXFLAGS -O3 -DNDEBUG"; 27 | ;; 28 | no) ;; 29 | *) AC_MSG_ERROR(bad value ${enableval} for --enable-optimize) ;; 30 | esac ], 31 | [ optimize=false ]) 32 | 33 | # Checks for programs. 34 | AC_PROG_CC 35 | AC_PROG_CXX 36 | AC_PROG_RANLIB 37 | AC_PROG_LEX 38 | AC_PROG_YACC 39 | 40 | # Create Makefiles 41 | AC_CONFIG_FILES([Makefile src/Makefile]) 42 | AC_OUTPUT 43 | -------------------------------------------------------------------------------- /doxygen-html/FlexLexer_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/FlexLexer.h File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/FlexLexer.h File Reference

26 |

27 | Go to the source code of this file. 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

Classes

class  FlexLexer
class  ExampleFlexLexer

Defines

#define FLEX_STD   std::
#define yyFlexLexerOnce

Typedefs

typedef int yy_state_type
43 |


Define Documentation

44 | 45 |
46 |
47 | 48 | 49 | 50 | 51 |
#define FLEX_STD   std::
52 |
53 |
54 | 55 |

56 | 57 |

Definition at line 53 of file FlexLexer.h.

58 | 59 |
60 |

61 | 62 |

63 |
64 | 65 | 66 | 67 | 68 |
#define yyFlexLexerOnce
69 |
70 |
71 | 72 |

73 | 74 |

Definition at line 108 of file FlexLexer.h.

75 | 76 |
77 |

78 |


Typedef Documentation

79 | 80 |
81 |
82 | 83 | 84 | 85 | 86 |
typedef int yy_state_type
87 |
88 |
89 | 90 |

91 | 92 |

Definition at line 58 of file FlexLexer.h.

93 | 94 |
95 |

96 |

97 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  98 | 99 | doxygen 1.5.9
100 | 101 | 102 | -------------------------------------------------------------------------------- /doxygen-html/classCNAdd-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNAdd Member List

This is the complete list of members for CNAdd, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNAdd(CalcNode *_left, CalcNode *_right)CNAdd [inline, explicit]
evaluate() const CNAdd [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNAdd [private]
print(std::ostream &os, unsigned int depth) const CNAdd [inline, virtual]
rightCNAdd [private]
~CalcNode()CalcNode [inline, virtual]
~CNAdd()CNAdd [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNAdd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNAdd.png -------------------------------------------------------------------------------- /doxygen-html/classCNConstant-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNConstant Member List

This is the complete list of members for CNConstant, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 |
CNConstant(double _value)CNConstant [inline, explicit]
evaluate() const CNConstant [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
print(std::ostream &os, unsigned int depth) const CNConstant [inline, virtual]
valueCNConstant [private]
~CalcNode()CalcNode [inline, virtual]

34 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  35 | 36 | doxygen 1.5.9
37 | 38 | 39 | -------------------------------------------------------------------------------- /doxygen-html/classCNConstant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNConstant.png -------------------------------------------------------------------------------- /doxygen-html/classCNDivide-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNDivide Member List

This is the complete list of members for CNDivide, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNDivide(CalcNode *_left, CalcNode *_right)CNDivide [inline, explicit]
evaluate() const CNDivide [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNDivide [private]
print(std::ostream &os, unsigned int depth) const CNDivide [inline, virtual]
rightCNDivide [private]
~CalcNode()CalcNode [inline, virtual]
~CNDivide()CNDivide [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNDivide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNDivide.png -------------------------------------------------------------------------------- /doxygen-html/classCNModulo-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNModulo Member List

This is the complete list of members for CNModulo, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNModulo(CalcNode *_left, CalcNode *_right)CNModulo [inline, explicit]
evaluate() const CNModulo [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNModulo [private]
print(std::ostream &os, unsigned int depth) const CNModulo [inline, virtual]
rightCNModulo [private]
~CalcNode()CalcNode [inline, virtual]
~CNModulo()CNModulo [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNModulo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNModulo.png -------------------------------------------------------------------------------- /doxygen-html/classCNMultiply-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNMultiply Member List

This is the complete list of members for CNMultiply, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNMultiply(CalcNode *_left, CalcNode *_right)CNMultiply [inline, explicit]
evaluate() const CNMultiply [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNMultiply [private]
print(std::ostream &os, unsigned int depth) const CNMultiply [inline, virtual]
rightCNMultiply [private]
~CalcNode()CalcNode [inline, virtual]
~CNMultiply()CNMultiply [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNMultiply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNMultiply.png -------------------------------------------------------------------------------- /doxygen-html/classCNNegate-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNNegate Member List

This is the complete list of members for CNNegate, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
CNNegate(CalcNode *_node)CNNegate [inline, explicit]
evaluate() const CNNegate [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
nodeCNNegate [private]
print(std::ostream &os, unsigned int depth) const CNNegate [inline, virtual]
~CalcNode()CalcNode [inline, virtual]
~CNNegate()CNNegate [inline, virtual]

35 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  36 | 37 | doxygen 1.5.9
38 | 39 | 40 | -------------------------------------------------------------------------------- /doxygen-html/classCNNegate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNNegate.png -------------------------------------------------------------------------------- /doxygen-html/classCNPower-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNPower Member List

This is the complete list of members for CNPower, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNPower(CalcNode *_left, CalcNode *_right)CNPower [inline, explicit]
evaluate() const CNPower [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNPower [private]
print(std::ostream &os, unsigned int depth) const CNPower [inline, virtual]
rightCNPower [private]
~CalcNode()CalcNode [inline, virtual]
~CNPower()CNPower [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNPower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNPower.png -------------------------------------------------------------------------------- /doxygen-html/classCNSubtract-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CNSubtract Member List

This is the complete list of members for CNSubtract, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
CNSubtract(CalcNode *_left, CalcNode *_right)CNSubtract [inline, explicit]
evaluate() const CNSubtract [inline, virtual]
indent(unsigned int d)CalcNode [inline, static]
leftCNSubtract [private]
print(std::ostream &os, unsigned int depth) const CNSubtract [inline, virtual]
rightCNSubtract [private]
~CalcNode()CalcNode [inline, virtual]
~CNSubtract()CNSubtract [inline, virtual]

36 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  37 | 38 | doxygen 1.5.9
39 | 40 | 41 | -------------------------------------------------------------------------------- /doxygen-html/classCNSubtract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCNSubtract.png -------------------------------------------------------------------------------- /doxygen-html/classCalcContext-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CalcContext Member List

This is the complete list of members for CalcContext, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
clearExpressions()CalcContext [inline]
existsVariable(const std::string &varname) const CalcContext [inline]
expressionsCalcContext
getVariable(const std::string &varname) const CalcContext [inline]
variablemap_type typedefCalcContext
variablesCalcContext
~CalcContext()CalcContext [inline]

35 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  36 | 37 | doxygen 1.5.9
38 | 39 | 40 | -------------------------------------------------------------------------------- /doxygen-html/classCalcNode-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

CalcNode Member List

This is the complete list of members for CalcNode, including all inherited members.

27 | 28 | 29 | 30 | 31 |
evaluate() const =0CalcNode [pure virtual]
indent(unsigned int d)CalcNode [inline, static]
print(std::ostream &os, unsigned int depth=0) const =0CalcNode [pure virtual]
~CalcNode()CalcNode [inline, virtual]

32 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  33 | 34 | doxygen 1.5.9
35 | 36 | 37 | -------------------------------------------------------------------------------- /doxygen-html/classCalcNode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classCalcNode.png -------------------------------------------------------------------------------- /doxygen-html/classExampleFlexLexer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classExampleFlexLexer.png -------------------------------------------------------------------------------- /doxygen-html/classFlexLexer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classFlexLexer.png -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1Driver-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::Driver Member List

This is the complete list of members for example::Driver, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
calcexample::Driver
Driver(class CalcContext &calc)example::Driver
error(const class location &l, const std::string &m)example::Driver
error(const std::string &m)example::Driver
lexerexample::Driver
parse_file(const std::string &filename)example::Driver
parse_stream(std::istream &in, const std::string &sname="stream input")example::Driver
parse_string(const std::string &input, const std::string &sname="string stream")example::Driver
streamnameexample::Driver
trace_parsingexample::Driver
trace_scanningexample::Driver

39 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  40 | 41 | doxygen 1.5.9
42 | 43 | 44 | -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1Scanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/classexample_1_1Scanner.png -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1location-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::location Member List

This is the complete list of members for example::location, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
beginexample::location
columns(unsigned int count=1)example::location [inline]
endexample::location
initialize(std::string *fn)example::location [inline]
lines(unsigned int count=1)example::location [inline]
location()example::location [inline]
step()example::location [inline]

35 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  36 | 37 | doxygen 1.5.9
38 | 39 | 40 | -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1position-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::position Member List

This is the complete list of members for example::position, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
columnexample::position
columns(int count=1)example::position [inline]
filenameexample::position
initialize(std::string *fn)example::position [inline]
lineexample::position
lines(int count=1)example::position [inline]
position()example::position [inline]

35 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  36 | 37 | doxygen 1.5.9
38 | 39 | 40 | -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1slice-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::slice< T, S > Member List

This is the complete list of members for example::slice< T, S >, including all inherited members.

27 | 28 | 29 | 30 | 31 |
operator[](unsigned int i) const example::slice< T, S > [inline]
range_example::slice< T, S > [private]
slice(const S &stack, unsigned int range)example::slice< T, S > [inline]
stack_example::slice< T, S > [private]

32 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  33 | 34 | doxygen 1.5.9
35 | 36 | 37 | -------------------------------------------------------------------------------- /doxygen-html/classexample_1_1stack-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::stack< T, S > Member List

This is the complete list of members for example::stack< T, S >, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
begin() const example::stack< T, S > [inline]
const_iterator typedefexample::stack< T, S >
end() const example::stack< T, S > [inline]
height() const example::stack< T, S > [inline]
iterator typedefexample::stack< T, S >
operator[](unsigned int i)example::stack< T, S > [inline]
operator[](unsigned int i) const example::stack< T, S > [inline]
pop(unsigned int n=1)example::stack< T, S > [inline]
push(const T &t)example::stack< T, S > [inline]
seq_example::stack< T, S > [private]
stack()example::stack< T, S > [inline]
stack(unsigned int n)example::stack< T, S > [inline]

40 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  41 | 42 | doxygen 1.5.9
43 | 44 | 45 | -------------------------------------------------------------------------------- /doxygen-html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/doxygen.png -------------------------------------------------------------------------------- /doxygen-html/driver_8cc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/driver.cc File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/driver.cc File Reference

Implementation of the example::Driver class. 26 | More... 27 |

28 | 29 |

30 | Go to the source code of this file. 31 | 32 | 33 | 34 | 35 | 36 | 37 |

38 |


Namespaces

namespace  example
 The example namespace is used to encapsulate the three parser classes example::Parser, example::Scanner and example::Driver.
39 |


Detailed Description

40 | Implementation of the example::Driver class. 41 |

42 | 43 |

Definition in file driver.cc.

44 |
45 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  46 | 47 | doxygen 1.5.9
48 | 49 | 50 | -------------------------------------------------------------------------------- /doxygen-html/driver_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/driver.h File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/driver.h File Reference

Declaration of the example::Driver class. 26 | More... 27 |

28 | 29 |

30 | Go to the source code of this file. 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |

42 |


Classes

class  example::Driver
 The Driver class brings together all components. More...

Namespaces

namespace  example
 The example namespace is used to encapsulate the three parser classes example::Parser, example::Scanner and example::Driver.
43 |


Detailed Description

44 | Declaration of the example::Driver class. 45 |

46 | 47 |

Definition in file driver.h.

48 |
49 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  50 | 51 | doxygen 1.5.9
52 | 53 | 54 | -------------------------------------------------------------------------------- /doxygen-html/exprtest_8cc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/exprtest.cc File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/exprtest.cc File Reference

26 |

27 | Go to the source code of this file. 28 | 29 | 30 | 31 | 32 |

Functions

int main (int argc, char *argv[])
33 |


Function Documentation

34 | 35 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
int main (int  argc,
char *  argv[] 
)
56 |
57 | 66 |

67 |

68 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  69 | 70 | doxygen 1.5.9
71 | 72 | 73 | -------------------------------------------------------------------------------- /doxygen-html/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: File Index 4 | 5 | 6 | 7 | 8 | 24 |
25 |

File List

Here is a list of all files with brief descriptions: 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
src/driver.cc [code]Implementation of the example::Driver class
src/driver.h [code]Declaration of the example::Driver class
src/expression.h [code]Implements an example calculator class group
src/exprtest.cc [code]
src/FlexLexer.h [code]
src/location.hh [code]Define the example::location class
src/parser.cc [code]
src/parser.h [code]
src/parser.yy [code]Contains the example Bison parser source
src/position.hh [code]Define the example::position class
src/scanner.cc [code]
src/scanner.h [code]
src/scanner.ll [code]Define the example Flex lexical scanner
src/stack.hh [code]
src/y.tab.h [code]Forwarding include file to parser.h (actually by including scanner.h)
42 |
43 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  44 | 45 | doxygen 1.5.9
46 | 47 | 48 | -------------------------------------------------------------------------------- /doxygen-html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- b -

65 |
66 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  67 | 68 | doxygen 1.5.9
69 | 70 | 71 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- d -

78 |
79 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  80 | 81 | doxygen 1.5.9
82 | 83 | 84 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x66.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- f -

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x67.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- g -

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x68.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- h -

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x69.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- i -

73 |
74 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  75 | 76 | doxygen 1.5.9
77 | 78 | 79 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x6e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- n -

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x6f.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- o -

66 |
67 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  68 | 69 | doxygen 1.5.9
70 | 71 | 72 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x72.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- r -

73 |
74 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  75 | 76 | doxygen 1.5.9
77 | 78 | 79 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x74.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- t -

70 |
71 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  72 | 73 | doxygen 1.5.9
74 | 75 | 76 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x76.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- v -

68 |
69 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  70 | 71 | doxygen 1.5.9
72 | 73 | 74 | -------------------------------------------------------------------------------- /doxygen-html/functions_0x7e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 57 |
58 | Here is a list of all class members with links to the classes they belong to: 59 |

60 |

- ~ -

88 |
89 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  90 | 91 | doxygen 1.5.9
92 | 93 | 94 | -------------------------------------------------------------------------------- /doxygen-html/functions_enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members - Enumerations 4 | 5 | 6 | 7 | 8 | 35 |
36 |   37 |

38 |

42 |
43 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  44 | 45 | doxygen 1.5.9
46 | 47 | 48 | -------------------------------------------------------------------------------- /doxygen-html/functions_eval.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members - Enumerator 4 | 5 | 6 | 7 | 8 | 35 |
36 |   37 |

38 |

50 |
51 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  52 | 53 | doxygen 1.5.9
54 | 55 | 56 | -------------------------------------------------------------------------------- /doxygen-html/functions_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members - Typedefs 4 | 5 | 6 | 7 | 8 | 35 |
36 |   37 |

38 |

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/globals_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 33 |
34 |   35 |

36 |

48 |
49 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  50 | 51 | doxygen 1.5.9
52 | 53 | 54 | -------------------------------------------------------------------------------- /doxygen-html/globals_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 33 |
34 |   35 |

36 |

64 |
65 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  66 | 67 | doxygen 1.5.9
68 | 69 | 70 | -------------------------------------------------------------------------------- /doxygen-html/globals_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 33 |
34 |   35 |

36 |

58 |
59 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  60 | 61 | doxygen 1.5.9
62 | 63 | 64 | -------------------------------------------------------------------------------- /doxygen-html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Hierarchical Index 4 | 5 | 6 | 7 | 8 | 25 |
26 |

Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically: 57 |
58 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  59 | 60 | doxygen 1.5.9
61 | 62 | 63 | -------------------------------------------------------------------------------- /doxygen-html/namespacemembers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 30 |
31 | Here is a list of all namespace members with links to the namespace documentation for each member: 32 |

33 |

49 |
50 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  51 | 52 | doxygen 1.5.9
53 | 54 | 55 | -------------------------------------------------------------------------------- /doxygen-html/namespacemembers_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Class Members 4 | 5 | 6 | 7 | 8 | 30 |
31 |   32 |

33 |

49 |
50 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  51 | 52 | doxygen 1.5.9
53 | 54 | 55 | -------------------------------------------------------------------------------- /doxygen-html/namespaces.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Namespace Index 4 | 5 | 6 | 7 | 8 | 24 |
25 |

Namespace List

Here is a list of all namespaces with brief descriptions: 26 | 27 |
exampleThe example namespace is used to encapsulate the three parser classes example::Parser, example::Scanner and example::Driver
28 |
29 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  30 | 31 | doxygen 1.5.9
32 | 33 | 34 | -------------------------------------------------------------------------------- /doxygen-html/parser_8yy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/parser.yy File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/parser.yy File Reference

Contains the example Bison parser source. 26 | More... 27 |

28 | 29 |

30 | Go to the source code of this file. 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 |

Defines

#define yylex   driver.lexer->lex

Variables

require debug start start
37 | defines skeleton lalr1 cc name 
prefix
40 |


Detailed Description

41 | Contains the example Bison parser source. 42 |

43 | 44 |

Definition in file parser.yy.

45 |

Define Documentation

46 | 47 |
48 |
49 | 50 | 51 | 52 | 53 |
#define yylex   driver.lexer->lex
54 |
55 |
56 | 57 |

58 | 59 |

60 |

61 |


Variable Documentation

62 | 63 |
64 |
65 | 66 | 67 | 68 | 69 |
require debug start start defines skeleton lalr1 cc name prefix
70 |
71 |
72 | 73 |

74 | Initial value:

"example"
75 | 
76 | 
77 | %define "parser_class_name" "Parser"
78 | 
79 | 
80 | %locations
81 | %initial-action
82 | {
83 |     
84 |     @$.begin.filename = @$.end.filename = &driver.streamname;
85 | }
86 | 
87 |

Definition at line 33 of file parser.yy.

88 | 89 |
90 |

91 |

92 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  93 | 94 | doxygen 1.5.9
95 | 96 | 97 | -------------------------------------------------------------------------------- /doxygen-html/readme_8dox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/readme.dox File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/readme.dox File Reference

Contains main doxygen example explanation page. 26 | More... 27 |

28 | 29 | 30 |
31 |


Detailed Description

32 | Contains main doxygen example explanation page. 33 |

34 | 35 |

Definition in file readme.dox.

36 |
37 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  38 | 39 | doxygen 1.5.9
40 | 41 | 42 | -------------------------------------------------------------------------------- /doxygen-html/stack_8hh.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/stack.hh File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/stack.hh File Reference

26 |

27 | Go to the source code of this file. 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |

41 |


Classes

class  example::stack< T, S >
class  example::slice< T, S >
 Present a slice of the top of a stack. More...

Namespaces

namespace  example
 The example namespace is used to encapsulate the three parser classes example::Parser, example::Scanner and example::Driver.
42 |

43 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  44 | 45 | doxygen 1.5.9
46 | 47 | 48 | -------------------------------------------------------------------------------- /doxygen-html/structexample_1_1Parser_1_1token-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::Parser::token Member List

This is the complete list of members for example::Parser::token, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 |
DOUBLE enum valueexample::Parser::token
END enum valueexample::Parser::token
EOL enum valueexample::Parser::token
INTEGER enum valueexample::Parser::token
STRING enum valueexample::Parser::token
yytokentype enum nameexample::Parser::token

34 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  35 | 36 | doxygen 1.5.9
37 | 38 | 39 | -------------------------------------------------------------------------------- /doxygen-html/structyy__buffer__state-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

yy_buffer_state Member List

This is the complete list of members for yy_buffer_state, including all inherited members.

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
yy_at_bolyy_buffer_state
yy_bs_columnyy_buffer_state
yy_bs_linenoyy_buffer_state
yy_buf_posyy_buffer_state
yy_buf_sizeyy_buffer_state
yy_buffer_statusyy_buffer_state
yy_ch_bufyy_buffer_state
yy_fill_bufferyy_buffer_state
yy_input_fileyy_buffer_state
yy_is_interactiveyy_buffer_state
yy_is_our_bufferyy_buffer_state
yy_n_charsyy_buffer_state

40 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  41 | 42 | doxygen 1.5.9
43 | 44 | 45 | -------------------------------------------------------------------------------- /doxygen-html/structyy__trans__info-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

yy_trans_info Member List

This is the complete list of members for yy_trans_info, including all inherited members.

27 | 28 | 29 |
yy_nxtyy_trans_info
yy_verifyyy_trans_info

30 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  31 | 32 | doxygen 1.5.9
33 | 34 | 35 | -------------------------------------------------------------------------------- /doxygen-html/structyy__trans__info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: yy_trans_info Struct Reference 4 | 5 | 6 | 7 | 8 | 25 |
26 |

yy_trans_info Struct Reference

27 |

28 | List of all members. 29 | 30 | 31 | 32 | 33 | 34 | 35 |

Public Attributes

flex_int32_t yy_verify
flex_int32_t yy_nxt
36 |


Detailed Description

37 | 38 |

Definition at line 404 of file scanner.cc.

39 |

Member Data Documentation

40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 |
flex_int32_t yy_trans_info::yy_nxt
48 |
49 |
50 | 51 |

52 | 53 |

Definition at line 407 of file scanner.cc.

54 | 55 |
56 |

57 | 58 |

59 |
60 | 61 | 62 | 63 | 64 |
flex_int32_t yy_trans_info::yy_verify
65 |
66 |
67 | 68 |

69 | 70 |

Definition at line 406 of file scanner.cc.

71 | 72 |
73 |

74 |


The documentation for this struct was generated from the following file: 76 |
77 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  78 | 79 | doxygen 1.5.9
80 | 81 | 82 | -------------------------------------------------------------------------------- /doxygen-html/tab_b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/tab_b.gif -------------------------------------------------------------------------------- /doxygen-html/tab_l.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/tab_l.gif -------------------------------------------------------------------------------- /doxygen-html/tab_r.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingmann/flex-bison-cpp-example/00ccee69dcf8ee3c8911b561508c67ceeafb921c/doxygen-html/tab_r.gif -------------------------------------------------------------------------------- /doxygen-html/tabs.css: -------------------------------------------------------------------------------- 1 | /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ 2 | 3 | DIV.tabs 4 | { 5 | float : left; 6 | width : 100%; 7 | background : url("tab_b.gif") repeat-x bottom; 8 | margin-bottom : 4px; 9 | } 10 | 11 | DIV.tabs UL 12 | { 13 | margin : 0px; 14 | padding-left : 10px; 15 | list-style : none; 16 | } 17 | 18 | DIV.tabs LI, DIV.tabs FORM 19 | { 20 | display : inline; 21 | margin : 0px; 22 | padding : 0px; 23 | } 24 | 25 | DIV.tabs FORM 26 | { 27 | float : right; 28 | } 29 | 30 | DIV.tabs A 31 | { 32 | float : left; 33 | background : url("tab_r.gif") no-repeat right top; 34 | border-bottom : 1px solid #84B0C7; 35 | font-size : 80%; 36 | font-weight : bold; 37 | text-decoration : none; 38 | } 39 | 40 | DIV.tabs A:hover 41 | { 42 | background-position: 100% -150px; 43 | } 44 | 45 | DIV.tabs A:link, DIV.tabs A:visited, 46 | DIV.tabs A:active, DIV.tabs A:hover 47 | { 48 | color: #1A419D; 49 | } 50 | 51 | DIV.tabs SPAN 52 | { 53 | float : left; 54 | display : block; 55 | background : url("tab_l.gif") no-repeat left top; 56 | padding : 5px 9px; 57 | white-space : nowrap; 58 | } 59 | 60 | DIV.tabs INPUT 61 | { 62 | float : right; 63 | display : inline; 64 | font-size : 1em; 65 | } 66 | 67 | DIV.tabs TD 68 | { 69 | font-size : 80%; 70 | font-weight : bold; 71 | text-decoration : none; 72 | } 73 | 74 | 75 | 76 | /* Commented Backslash Hack hides rule from IE5-Mac \*/ 77 | DIV.tabs SPAN {float : none;} 78 | /* End IE5-Mac hack */ 79 | 80 | DIV.tabs A:hover SPAN 81 | { 82 | background-position: 0% -150px; 83 | } 84 | 85 | DIV.tabs LI.current A 86 | { 87 | background-position: 100% -150px; 88 | border-width : 0px; 89 | } 90 | 91 | DIV.tabs LI.current SPAN 92 | { 93 | background-position: 0% -150px; 94 | padding-bottom : 6px; 95 | } 96 | 97 | DIV.navpath 98 | { 99 | background : none; 100 | border : none; 101 | border-bottom : 1px solid #84B0C7; 102 | text-align : center; 103 | margin : 2px; 104 | padding : 2px; 105 | } 106 | -------------------------------------------------------------------------------- /doxygen-html/unionexample_1_1Parser_1_1semantic__type-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: Member List 4 | 5 | 6 | 7 | 8 | 25 |
26 |

example::Parser::semantic_type Member List

This is the complete list of members for example::Parser::semantic_type, including all inherited members.

27 | 28 | 29 | 30 | 31 |
calcnodeexample::Parser::semantic_type
doubleValexample::Parser::semantic_type
integerValexample::Parser::semantic_type
stringValexample::Parser::semantic_type

32 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  33 | 34 | doxygen 1.5.9
35 | 36 | 37 | -------------------------------------------------------------------------------- /doxygen-html/y_8tab_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/y.tab.h File Reference 4 | 5 | 6 | 7 | 8 | 24 |
25 |

src/y.tab.h File Reference

Forwarding include file to parser.h (actually by including scanner.h). 26 | More... 27 |

28 | 29 |

30 | Go to the source code of this file. 31 | 32 |
33 |


Detailed Description

34 | Forwarding include file to parser.h (actually by including scanner.h). 35 |

36 | 37 |

Definition in file y.tab.h.

38 |
39 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  40 | 41 | doxygen 1.5.9
42 | 43 | 44 | -------------------------------------------------------------------------------- /doxygen-html/y_8tab_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flex Bison C++ Example: src/y.tab.h Source File 4 | 5 | 6 | 7 | 8 | 35 |
Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  36 | 37 | doxygen 1.5.9
38 | 39 | 40 | -------------------------------------------------------------------------------- /flex-bison-cpp-example.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "exprtest", "src\exprtest.vcproj", "{593B904F-87DE-4A3C-85BD-0BDD5F939C0F}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {599F27DC-A593-4E7C-A461-D7B3198118B0} = {599F27DC-A593-4E7C-A461-D7B3198118B0} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libexampleparser", "src\libexampleparser.vcproj", "{599F27DC-A593-4E7C-A461-D7B3198118B0}" 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Release|Win32 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {593B904F-87DE-4A3C-85BD-0BDD5F939C0F}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {593B904F-87DE-4A3C-85BD-0BDD5F939C0F}.Debug|Win32.Build.0 = Debug|Win32 19 | {593B904F-87DE-4A3C-85BD-0BDD5F939C0F}.Release|Win32.ActiveCfg = Release|Win32 20 | {593B904F-87DE-4A3C-85BD-0BDD5F939C0F}.Release|Win32.Build.0 = Release|Win32 21 | {599F27DC-A593-4E7C-A461-D7B3198118B0}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {599F27DC-A593-4E7C-A461-D7B3198118B0}.Debug|Win32.Build.0 = Debug|Win32 23 | {599F27DC-A593-4E7C-A461-D7B3198118B0}.Release|Win32.ActiveCfg = Release|Win32 24 | {599F27DC-A593-4E7C-A461-D7B3198118B0}.Release|Win32.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | AM_CFLAGS = -W -Wall -Wextra -ansi 4 | AM_CXXFLAGS = -W -Wall -Wextra -ansi 5 | 6 | noinst_LIBRARIES = libexampleparser.a 7 | 8 | libexampleparser_a_SOURCES = \ 9 | parser.yy scanner.ll parser.h scanner.h y.tab.h \ 10 | location.hh position.hh stack.hh FlexLexer.h \ 11 | driver.cc driver.h expression.h 12 | 13 | bin_PROGRAMS = exprtest 14 | 15 | exprtest_SOURCES = exprtest.cc 16 | exprtest_DEPENDENCIES = libexampleparser.a 17 | 18 | LIBS = libexampleparser.a 19 | 20 | # this output override is needed because the c++ scanner is outputted into 21 | # lex.yy.cc and the automake ylwrap script only checks for lex.yy.c 22 | AM_LFLAGS = -olex.yy.c 23 | 24 | EXTRA_DIST = readme.dox exprtest.txt \ 25 | exprtest.vcproj libexampleparser.vcproj \ 26 | Makefile.plain 27 | 28 | extraclean: 29 | rm -f parser.cc parser.h scanner.cc 30 | 31 | rebuild: clean extraclean all -------------------------------------------------------------------------------- /src/Makefile.plain: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # plain simple Makefile to build exprtest 3 | 4 | CXX = g++ 5 | LEX = flex 6 | YACC = bison 7 | 8 | CXXFLAGS = -W -Wall -Wextra -ansi -g 9 | LDFLAGS = 10 | 11 | HEADERS = driver.h parser.h scanner.h expression.h \ 12 | y.tab.h FlexLexer.h location.hh position.hh stack.hh 13 | 14 | all: exprtest 15 | 16 | # Generate scanner and parser 17 | 18 | parser.cc: parser.yy 19 | $(YACC) -o parser.cc --defines=parser.h parser.yy 20 | 21 | scanner.cc: scanner.ll 22 | $(LEX) -o scanner.cc scanner.ll 23 | 24 | # Implicit rule to compile c++ files 25 | 26 | %.o: %.cc 27 | $(CXX) $(CXXFLAGS) -c -o $@ $< 28 | 29 | # Link executable 30 | 31 | exprtest: exprtest.o parser.o scanner.o driver.o 32 | $(CXX) $(LDFLAGS) -o $@ exprtest.o parser.o scanner.o driver.o 33 | 34 | clean: 35 | rm -f exprtest *.o 36 | 37 | extraclean: clean 38 | rm -f parser.cc parser.h scanner.cc 39 | -------------------------------------------------------------------------------- /src/driver.cc: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | /** \file driver.cc Implementation of the example::Driver class. */ 3 | 4 | #include 5 | #include 6 | 7 | #include "driver.h" 8 | #include "scanner.h" 9 | 10 | namespace example { 11 | 12 | Driver::Driver(class CalcContext& _calc) 13 | : trace_scanning(false), 14 | trace_parsing(false), 15 | calc(_calc) 16 | { 17 | } 18 | 19 | bool Driver::parse_stream(std::istream& in, const std::string& sname) 20 | { 21 | streamname = sname; 22 | 23 | Scanner scanner(&in); 24 | scanner.set_debug(trace_scanning); 25 | this->lexer = &scanner; 26 | 27 | Parser parser(*this); 28 | parser.set_debug_level(trace_parsing); 29 | return (parser.parse() == 0); 30 | } 31 | 32 | bool Driver::parse_file(const std::string &filename) 33 | { 34 | std::ifstream in(filename.c_str()); 35 | if (!in.good()) return false; 36 | return parse_stream(in, filename); 37 | } 38 | 39 | bool Driver::parse_string(const std::string &input, const std::string& sname) 40 | { 41 | std::istringstream iss(input); 42 | return parse_stream(iss, sname); 43 | } 44 | 45 | void Driver::error(const class location& l, 46 | const std::string& m) 47 | { 48 | std::cerr << l << ": " << m << std::endl; 49 | } 50 | 51 | void Driver::error(const std::string& m) 52 | { 53 | std::cerr << m << std::endl; 54 | } 55 | 56 | } // namespace example 57 | -------------------------------------------------------------------------------- /src/driver.h: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | /** \file driver.h Declaration of the example::Driver class. */ 3 | 4 | #ifndef EXAMPLE_DRIVER_H 5 | #define EXAMPLE_DRIVER_H 6 | 7 | #include 8 | #include 9 | 10 | // forward declaration 11 | class CalcContext; 12 | 13 | /** The example namespace is used to encapsulate the three parser classes 14 | * example::Parser, example::Scanner and example::Driver */ 15 | namespace example { 16 | 17 | /** The Driver class brings together all components. It creates an instance of 18 | * the Parser and Scanner classes and connects them. Then the input stream is 19 | * fed into the scanner object and the parser gets it's token 20 | * sequence. Furthermore the driver object is available in the grammar rules as 21 | * a parameter. Therefore the driver class contains a reference to the 22 | * structure into which the parsed data is saved. */ 23 | class Driver 24 | { 25 | public: 26 | /// construct a new parser driver context 27 | Driver(class CalcContext& calc); 28 | 29 | /// enable debug output in the flex scanner 30 | bool trace_scanning; 31 | 32 | /// enable debug output in the bison parser 33 | bool trace_parsing; 34 | 35 | /// stream name (file or input stream) used for error messages. 36 | std::string streamname; 37 | 38 | /** Invoke the scanner and parser for a stream. 39 | * @param in input stream 40 | * @param sname stream name for error messages 41 | * @return true if successfully parsed 42 | */ 43 | bool parse_stream(std::istream& in, 44 | const std::string& sname = "stream input"); 45 | 46 | /** Invoke the scanner and parser on an input string. 47 | * @param input input string 48 | * @param sname stream name for error messages 49 | * @return true if successfully parsed 50 | */ 51 | bool parse_string(const std::string& input, 52 | const std::string& sname = "string stream"); 53 | 54 | /** Invoke the scanner and parser on a file. Use parse_stream with a 55 | * std::ifstream if detection of file reading errors is required. 56 | * @param filename input file name 57 | * @return true if successfully parsed 58 | */ 59 | bool parse_file(const std::string& filename); 60 | 61 | // To demonstrate pure handling of parse errors, instead of 62 | // simply dumping them on the standard error output, we will pass 63 | // them to the driver using the following two member functions. 64 | 65 | /** Error handling with associated line number. This can be modified to 66 | * output the error e.g. to a dialog box. */ 67 | void error(const class location& l, const std::string& m); 68 | 69 | /** General error handling. This can be modified to output the error 70 | * e.g. to a dialog box. */ 71 | void error(const std::string& m); 72 | 73 | /** Pointer to the current lexer instance, this is used to connect the 74 | * parser to the scanner. It is used in the yylex macro. */ 75 | class Scanner* lexer; 76 | 77 | /** Reference to the calculator context filled during parsing of the 78 | * expressions. */ 79 | class CalcContext& calc; 80 | }; 81 | 82 | } // namespace example 83 | 84 | #endif // EXAMPLE_DRIVER_H 85 | -------------------------------------------------------------------------------- /src/exprtest.cc: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | #include 4 | #include 5 | 6 | #include "driver.h" 7 | #include "expression.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | CalcContext calc; 12 | example::Driver driver(calc); 13 | bool readfile = false; 14 | 15 | for(int ai = 1; ai < argc; ++ai) 16 | { 17 | if (argv[ai] == std::string ("-p")) { 18 | driver.trace_parsing = true; 19 | } 20 | else if (argv[ai] == std::string ("-s")) { 21 | driver.trace_scanning = true; 22 | } 23 | else 24 | { 25 | // read a file with expressions 26 | 27 | std::fstream infile(argv[ai]); 28 | if (!infile.good()) 29 | { 30 | std::cerr << "Could not open file: " << argv[ai] << std::endl; 31 | return 0; 32 | } 33 | 34 | calc.clearExpressions(); 35 | bool result = driver.parse_stream(infile, argv[ai]); 36 | if (result) 37 | { 38 | std::cout << "Expressions:" << std::endl; 39 | for (unsigned int ei = 0; ei < calc.expressions.size(); ++ei) 40 | { 41 | std::cout << "[" << ei << "]:" << std::endl; 42 | std::cout << "tree:" << std::endl; 43 | calc.expressions[ei]->print(std::cout); 44 | std::cout << "evaluated: " 45 | << calc.expressions[ei]->evaluate() 46 | << std::endl; 47 | } 48 | } 49 | 50 | readfile = true; 51 | } 52 | } 53 | 54 | if (readfile) return 0; 55 | 56 | std::cout << "Reading expressions from stdin" << std::endl; 57 | 58 | std::string line; 59 | while( std::cout << "input: " && 60 | std::getline(std::cin, line) && 61 | !line.empty() ) 62 | { 63 | calc.clearExpressions(); 64 | bool result = driver.parse_string(line, "input"); 65 | 66 | if (result) 67 | { 68 | for (unsigned int ei = 0; ei < calc.expressions.size(); ++ei) 69 | { 70 | std::cout << "tree:" << std::endl; 71 | calc.expressions[ei]->print(std::cout); 72 | std::cout << "evaluated: " 73 | << calc.expressions[ei]->evaluate() 74 | << std::endl; 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/exprtest.txt: -------------------------------------------------------------------------------- 1 | 2 | v = (2 ^ 4 - 4); e = 2.71828 3 | 4 | 4 * 1.5 + 3 * v 5 | 6 | 6 * (2 * 2) ^ 2 / 2 7 | 8 | -------------------------------------------------------------------------------- /src/exprtest.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 26 | 29 | 32 | 35 | 38 | 41 | 53 | 56 | 59 | 62 | 69 | 72 | 75 | 78 | 81 | 84 | 87 | 90 | 93 | 94 | 103 | 106 | 109 | 112 | 115 | 118 | 127 | 130 | 133 | 136 | 145 | 148 | 151 | 154 | 157 | 160 | 163 | 166 | 169 | 170 | 171 | 172 | 173 | 174 | 177 | 178 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /src/libexampleparser.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 53 | 56 | 59 | 62 | 65 | 68 | 71 | 74 | 77 | 80 | 81 | 89 | 92 | 95 | 98 | 101 | 104 | 114 | 117 | 120 | 123 | 126 | 129 | 132 | 135 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 149 | 150 | 153 | 154 | 157 | 158 | 161 | 162 | 165 | 166 | 169 | 170 | 173 | 174 | 177 | 178 | 181 | 182 | 185 | 186 | 189 | 190 | 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /src/position.hh: -------------------------------------------------------------------------------- 1 | 2 | /* A Bison parser, made by GNU Bison 2.4.1. */ 3 | 4 | /* Positions for Bison parsers in C++ 5 | 6 | Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . */ 20 | 21 | /* As a special exception, you may create a larger work that contains 22 | part or all of the Bison parser skeleton and distribute that work 23 | under terms of your choice, so long as that work isn't itself a 24 | parser generator using the skeleton or a modified version thereof 25 | as a parser skeleton. Alternatively, if you modify or redistribute 26 | the parser skeleton itself, you may (at your option) remove this 27 | special exception, which will cause the skeleton and the resulting 28 | Bison output files to be licensed under the GNU General Public 29 | License without this special exception. 30 | 31 | This special exception was added by the Free Software Foundation in 32 | version 2.2 of Bison. */ 33 | 34 | /** 35 | ** \file position.hh 36 | ** Define the example::position class. 37 | */ 38 | 39 | #ifndef BISON_POSITION_HH 40 | # define BISON_POSITION_HH 41 | 42 | # include 43 | # include 44 | # include 45 | 46 | 47 | /* Line 38 of location.cc */ 48 | #line 1 "[Bison:b4_percent_define_default]" 49 | 50 | namespace example { 51 | 52 | /* Line 38 of location.cc */ 53 | #line 54 "position.hh" 54 | /// Abstract a position. 55 | class position 56 | { 57 | public: 58 | 59 | /// Construct a position. 60 | position () 61 | : filename (0), line (1), column (1) 62 | { 63 | } 64 | 65 | 66 | /// Initialization. 67 | inline void initialize (std::string* fn) 68 | { 69 | filename = fn; 70 | line = 1; 71 | column = 1; 72 | } 73 | 74 | /** \name Line and Column related manipulators 75 | ** \{ */ 76 | public: 77 | /// (line related) Advance to the COUNT next lines. 78 | inline void lines (int count = 1) 79 | { 80 | column = 1; 81 | line += count; 82 | } 83 | 84 | /// (column related) Advance to the COUNT next columns. 85 | inline void columns (int count = 1) 86 | { 87 | column = std::max (1u, column + count); 88 | } 89 | /** \} */ 90 | 91 | public: 92 | /// File name to which this position refers. 93 | std::string* filename; 94 | /// Current line number. 95 | unsigned int line; 96 | /// Current column number. 97 | unsigned int column; 98 | }; 99 | 100 | /// Add and assign a position. 101 | inline const position& 102 | operator+= (position& res, const int width) 103 | { 104 | res.columns (width); 105 | return res; 106 | } 107 | 108 | /// Add two position objects. 109 | inline const position 110 | operator+ (const position& begin, const int width) 111 | { 112 | position res = begin; 113 | return res += width; 114 | } 115 | 116 | /// Add and assign a position. 117 | inline const position& 118 | operator-= (position& res, const int width) 119 | { 120 | return res += -width; 121 | } 122 | 123 | /// Add two position objects. 124 | inline const position 125 | operator- (const position& begin, const int width) 126 | { 127 | return begin + -width; 128 | } 129 | 130 | /// Compare two position objects. 131 | inline bool 132 | operator== (const position& pos1, const position& pos2) 133 | { 134 | return 135 | (pos1.filename == pos2.filename 136 | || (pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)) 137 | && pos1.line == pos2.line && pos1.column == pos2.column; 138 | } 139 | 140 | /// Compare two position objects. 141 | inline bool 142 | operator!= (const position& pos1, const position& pos2) 143 | { 144 | return !(pos1 == pos2); 145 | } 146 | 147 | /** \brief Intercept output stream redirection. 148 | ** \param ostr the destination output stream 149 | ** \param pos a reference to the position to redirect 150 | */ 151 | inline std::ostream& 152 | operator<< (std::ostream& ostr, const position& pos) 153 | { 154 | if (pos.filename) 155 | ostr << *pos.filename << ':'; 156 | return ostr << pos.line << '.' << pos.column; 157 | } 158 | 159 | 160 | /* Line 144 of location.cc */ 161 | #line 1 "[Bison:b4_percent_define_default]" 162 | 163 | } // example 164 | 165 | /* Line 144 of location.cc */ 166 | #line 167 "position.hh" 167 | #endif // not BISON_POSITION_HH 168 | -------------------------------------------------------------------------------- /src/scanner.h: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | #ifndef EXAMPLE_SCANNER_H 4 | #define EXAMPLE_SCANNER_H 5 | 6 | // Flex expects the signature of yylex to be defined in the macro YY_DECL, and 7 | // the C++ parser expects it to be declared. We can factor both as follows. 8 | 9 | #ifndef YY_DECL 10 | 11 | #define YY_DECL \ 12 | example::Parser::token_type \ 13 | example::Scanner::lex( \ 14 | example::Parser::semantic_type* yylval, \ 15 | example::Parser::location_type* yylloc \ 16 | ) 17 | #endif 18 | 19 | #ifndef __FLEX_LEXER_H 20 | #define yyFlexLexer ExampleFlexLexer 21 | #include "FlexLexer.h" 22 | #undef yyFlexLexer 23 | #endif 24 | 25 | #include "parser.h" 26 | 27 | namespace example { 28 | 29 | /** Scanner is a derived class to add some extra function to the scanner 30 | * class. Flex itself creates a class named yyFlexLexer, which is renamed using 31 | * macros to ExampleFlexLexer. However we change the context of the generated 32 | * yylex() function to be contained within the Scanner class. This is required 33 | * because the yylex() defined in ExampleFlexLexer has no parameters. */ 34 | class Scanner : public ExampleFlexLexer 35 | { 36 | public: 37 | /** Create a new scanner object. The streams arg_yyin and arg_yyout default 38 | * to cin and cout, but that assignment is only made when initializing in 39 | * yylex(). */ 40 | Scanner(std::istream* arg_yyin = 0, 41 | std::ostream* arg_yyout = 0); 42 | 43 | /** Required for virtual functions */ 44 | virtual ~Scanner(); 45 | 46 | /** This is the main lexing function. It is generated by flex according to 47 | * the macro declaration YY_DECL above. The generated bison parser then 48 | * calls this virtual function to fetch new tokens. */ 49 | virtual Parser::token_type lex( 50 | Parser::semantic_type* yylval, 51 | Parser::location_type* yylloc 52 | ); 53 | 54 | /** Enable debug output (via arg_yyout) if compiled into the scanner. */ 55 | void set_debug(bool b); 56 | }; 57 | 58 | } // namespace example 59 | 60 | #endif // EXAMPLE_SCANNER_H 61 | -------------------------------------------------------------------------------- /src/scanner.ll: -------------------------------------------------------------------------------- 1 | /* $Id$ -*- mode: c++ -*- */ 2 | /** \file scanner.ll Define the example Flex lexical scanner */ 3 | 4 | %{ /*** C/C++ Declarations ***/ 5 | 6 | #include 7 | 8 | #include "scanner.h" 9 | 10 | /* import the parser's token type into a local typedef */ 11 | typedef example::Parser::token token; 12 | typedef example::Parser::token_type token_type; 13 | 14 | /* By default yylex returns int, we use token_type. Unfortunately yyterminate 15 | * by default returns 0, which is not of token_type. */ 16 | #define yyterminate() return token::END 17 | 18 | /* This disables inclusion of unistd.h, which is not available under Visual C++ 19 | * on Win32. The C++ scanner uses STL streams instead. */ 20 | #define YY_NO_UNISTD_H 21 | 22 | %} 23 | 24 | /*** Flex Declarations and Options ***/ 25 | 26 | /* enable c++ scanner class generation */ 27 | %option c++ 28 | 29 | /* change the name of the scanner class. results in "ExampleFlexLexer" */ 30 | %option prefix="Example" 31 | 32 | /* the manual says "somewhat more optimized" */ 33 | %option batch 34 | 35 | /* enable scanner to generate debug output. disable this for release 36 | * versions. */ 37 | %option debug 38 | 39 | /* no support for include files is planned */ 40 | %option yywrap nounput 41 | 42 | /* enables the use of start condition stacks */ 43 | %option stack 44 | 45 | /* The following paragraph suffices to track locations accurately. Each time 46 | * yylex is invoked, the begin position is moved onto the end position. */ 47 | %{ 48 | #define YY_USER_ACTION yylloc->columns(yyleng); 49 | %} 50 | 51 | %% /*** Regular Expressions Part ***/ 52 | 53 | /* code to place at the beginning of yylex() */ 54 | %{ 55 | // reset location 56 | yylloc->step(); 57 | %} 58 | 59 | /*** BEGIN EXAMPLE - Change the example lexer rules below ***/ 60 | 61 | [0-9]+ { 62 | yylval->integerVal = atoi(yytext); 63 | return token::INTEGER; 64 | } 65 | 66 | [0-9]+"."[0-9]* { 67 | yylval->doubleVal = atof(yytext); 68 | return token::DOUBLE; 69 | } 70 | 71 | [A-Za-z][A-Za-z0-9_,.-]* { 72 | yylval->stringVal = new std::string(yytext, yyleng); 73 | return token::STRING; 74 | } 75 | 76 | /* gobble up white-spaces */ 77 | [ \t\r]+ { 78 | yylloc->step(); 79 | } 80 | 81 | /* gobble up end-of-lines */ 82 | \n { 83 | yylloc->lines(yyleng); yylloc->step(); 84 | return token::EOL; 85 | } 86 | 87 | /* pass all other characters up to bison */ 88 | . { 89 | return static_cast(*yytext); 90 | } 91 | 92 | /*** END EXAMPLE - Change the example lexer rules above ***/ 93 | 94 | %% /*** Additional Code ***/ 95 | 96 | namespace example { 97 | 98 | Scanner::Scanner(std::istream* in, 99 | std::ostream* out) 100 | : ExampleFlexLexer(in, out) 101 | { 102 | } 103 | 104 | Scanner::~Scanner() 105 | { 106 | } 107 | 108 | void Scanner::set_debug(bool b) 109 | { 110 | yy_flex_debug = b; 111 | } 112 | 113 | } 114 | 115 | /* This implementation of ExampleFlexLexer::yylex() is required to fill the 116 | * vtable of the class ExampleFlexLexer. We define the scanner's main yylex 117 | * function via YY_DECL to reside in the Scanner class instead. */ 118 | 119 | #ifdef yylex 120 | #undef yylex 121 | #endif 122 | 123 | int ExampleFlexLexer::yylex() 124 | { 125 | std::cerr << "in ExampleFlexLexer::yylex() !" << std::endl; 126 | return 0; 127 | } 128 | 129 | /* When the scanner receives an end-of-file indication from YY_INPUT, it then 130 | * checks the yywrap() function. If yywrap() returns false (zero), then it is 131 | * assumed that the function has gone ahead and set up `yyin' to point to 132 | * another input file, and scanning continues. If it returns true (non-zero), 133 | * then the scanner terminates, returning 0 to its caller. */ 134 | 135 | int ExampleFlexLexer::yywrap() 136 | { 137 | return 1; 138 | } 139 | -------------------------------------------------------------------------------- /src/stack.hh: -------------------------------------------------------------------------------- 1 | 2 | /* A Bison parser, made by GNU Bison 2.4.1. */ 3 | 4 | /* Stack handling for Bison parsers in C++ 5 | 6 | Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software 7 | Foundation, Inc. 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . */ 21 | 22 | /* As a special exception, you may create a larger work that contains 23 | part or all of the Bison parser skeleton and distribute that work 24 | under terms of your choice, so long as that work isn't itself a 25 | parser generator using the skeleton or a modified version thereof 26 | as a parser skeleton. Alternatively, if you modify or redistribute 27 | the parser skeleton itself, you may (at your option) remove this 28 | special exception, which will cause the skeleton and the resulting 29 | Bison output files to be licensed under the GNU General Public 30 | License without this special exception. 31 | 32 | This special exception was added by the Free Software Foundation in 33 | version 2.2 of Bison. */ 34 | 35 | #ifndef BISON_STACK_HH 36 | # define BISON_STACK_HH 37 | 38 | #include 39 | 40 | 41 | /* Line 1067 of lalr1.cc */ 42 | #line 1 "[Bison:b4_percent_define_default]" 43 | 44 | namespace example { 45 | 46 | /* Line 1067 of lalr1.cc */ 47 | #line 48 "stack.hh" 48 | template > 49 | class stack 50 | { 51 | public: 52 | 53 | // Hide our reversed order. 54 | typedef typename S::reverse_iterator iterator; 55 | typedef typename S::const_reverse_iterator const_iterator; 56 | 57 | stack () : seq_ () 58 | { 59 | } 60 | 61 | stack (unsigned int n) : seq_ (n) 62 | { 63 | } 64 | 65 | inline 66 | T& 67 | operator [] (unsigned int i) 68 | { 69 | return seq_[i]; 70 | } 71 | 72 | inline 73 | const T& 74 | operator [] (unsigned int i) const 75 | { 76 | return seq_[i]; 77 | } 78 | 79 | inline 80 | void 81 | push (const T& t) 82 | { 83 | seq_.push_front (t); 84 | } 85 | 86 | inline 87 | void 88 | pop (unsigned int n = 1) 89 | { 90 | for (; n; --n) 91 | seq_.pop_front (); 92 | } 93 | 94 | inline 95 | unsigned int 96 | height () const 97 | { 98 | return seq_.size (); 99 | } 100 | 101 | inline const_iterator begin () const { return seq_.rbegin (); } 102 | inline const_iterator end () const { return seq_.rend (); } 103 | 104 | private: 105 | 106 | S seq_; 107 | }; 108 | 109 | /// Present a slice of the top of a stack. 110 | template > 111 | class slice 112 | { 113 | public: 114 | 115 | slice (const S& stack, 116 | unsigned int range) : stack_ (stack), 117 | range_ (range) 118 | { 119 | } 120 | 121 | inline 122 | const T& 123 | operator [] (unsigned int i) const 124 | { 125 | return stack_[range_ - i]; 126 | } 127 | 128 | private: 129 | 130 | const S& stack_; 131 | unsigned int range_; 132 | }; 133 | 134 | /* Line 1153 of lalr1.cc */ 135 | #line 1 "[Bison:b4_percent_define_default]" 136 | 137 | } // example 138 | 139 | /* Line 1153 of lalr1.cc */ 140 | #line 141 "stack.hh" 141 | 142 | #endif // not BISON_STACK_HH[]dnl 143 | 144 | -------------------------------------------------------------------------------- /src/y.tab.h: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | /** \file y.tab.h Forwarding include file to parser.h (actually by including scanner.h) */ 3 | 4 | /* When using automake the bison parser file "xyz.yy" is processed by the 5 | * ylwrap script. It calls bison in a separate directory, which outputs source 6 | * to the default names "y.tab.c" and "y.tab.h". The ylwrap script then renames 7 | * these files into "xyz.cc" and "xyz.h" and tries to update include references 8 | * using sed. However this does not work for the C++ parser skeleton, so the 9 | * source file "xyz.cc" still refers to the default "y.tab.h". The easiest 10 | * work-around is to use this forwarding include file. */ 11 | 12 | #include "scanner.h" 13 | 14 | --------------------------------------------------------------------------------