OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [new_compiler/] [Scanner.h] - Blame information for rev 216

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 206 diegovalve
/* This program is free software. It comes without any warranty, to
2
 * the extent permitted by applicable law. You can redistribute it
3
 * and/or modify it under the terms of the Do What The Fuck You Want
4
 * To Public License, Version 2, as published by Sam Hocevar. See
5
 * http://sam.zoy.org/wtfpl/COPYING for more details. */
6
 
7
#pragma once
8
 
9
// Only include FlexLexer.h if it hasn't been already included
10
#if ! defined(yyFlexLexerOnce)
11
#include <FlexLexer.h>
12
#endif
13
 
14
// Override the interface for yylex since we namespaced it
15
#undef YY_DECL
16
#define YY_DECL int Theia::Scanner::yylex()
17
 
18
// Include Bison for types / tokens
19
#include "parser.tab.h"
20
 
21
 
22
 
23
        namespace Theia
24
        {
25
                class Scanner : public yyFlexLexer
26
                {
27
                        public:
28
                                // constructor accepts the input and output streams
29
                                // 0 means std equivilant (stdin, stdout)
30
                                Scanner(std::istream * in = 0, std::ostream * out = 0) : yyFlexLexer(in, out) { }
31
 
32
                                // overloaded version of yylex - we need a pointer to yylval and yylloc
33
                                inline int yylex(Parser::semantic_type * lval,
34
                                                 Parser::location_type * lloc);
35
 
36
                        private:
37
                                // Scanning function created by Flex; make this private to force usage
38
                                // of the overloaded method so we can get a pointer to Bison's yylval
39
                                int yylex();
40
 
41
                                // point to yylval (provided by Bison in overloaded yylex)
42
                                Parser::semantic_type * yylval;
43
 
44
                                // pointer to yylloc (provided by Bison in overloaded yylex)
45
                                Parser::location_type * yylloc;
46
 
47
                                // block default constructor
48
                                Scanner();
49
                                // block default copy constructor
50
                                Scanner(Scanner const &rhs);
51
                                // block default assignment operator
52
                                Scanner &operator=(Scanner const &rhs);
53
                };
54
 
55
                // all our overloaded version does is save yylval and yylloc to member variables
56
                // and invoke the generated scanner
57
                int Scanner::yylex(Parser::semantic_type * lval,
58
                                   Parser::location_type * lloc) {
59
                        yylval = lval;
60
                        yylloc = lloc;
61
                        return yylex();
62
                }
63
 
64
        }
65
//}
66
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.