source: trunk/orbital/gun-compiler.h @ 1519

Last change on this file since 1519 was 1424, checked in by sam, 11 years ago

orbital: port the gun command compiler to our bison/flex system.

File size: 1.1 KB
RevLine 
[1424]1//
2// Orbital
3//
4// Copyright: (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
5//            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
6//            (c) 2012 Sam Hocevar <sam@hocevar.net>
7//
8
9#ifndef __GUN_COMPILER_H__
10#define __GUN_COMPILER_H__
11
12#include <string>
13
14#ifndef __FLEX_LEXER_H
15#   define yyFlexLexer GunFlexLexer
16#   include "FlexLexer.h"
17#   undef yyFlexLexer
18#endif
19
20#include "generated/gun-parser.h"
21
22class Gun;
23
24namespace orbital {
25
26class GunScanner : public GunFlexLexer
27{
28public:
29    GunScanner(char const *command);
30    virtual ~GunScanner();
31    virtual int LexerInput(char* buf, int max_size);
32    virtual GunParser::token_type lex(GunParser::semantic_type* yylval,
33                                      GunParser::location_type* yylloc);
34
35private:
36    char const *m_input;
37};
38
39class GunCompiler
40{
41public:
42    GunCompiler(class Gun &gun);
43
44    bool ParseString(char const *command);
45
46    void Error(const class location& l, const std::string& m);
47    void Error(const std::string& m);
48
49    class GunScanner* m_lexer;
50    class Gun &m_gun;
51};
52
53}
54
55#endif /* __GUN_COMPILER_H__ */
56
Note: See TracBrowser for help on using the repository browser.