aboutsummaryrefslogtreecommitdiff
path: root/src/buildparser.h
blob: 5e92895780ebb348cfcacac1863bfa12cbdf50ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright (C) 2007-2014 Xagasoft, All rights reserved.
 *
 * This file is part of the Xagasoft Build and is released under the
 * terms of the license contained in the file LICENSE.
 */

#ifndef BUILD_PARSER_H
#define BUILD_PARSER_H

typedef void * yyscan_t;
class BuildParser;
#include "build.tab.h"

#include "bu/stack.h"
#include "bu/string.h"
#include "types.h"

class BuildParser
{
public:
    BuildParser( class Ast &rAst );
    virtual ~BuildParser();

    void load( const Bu::String &sFile );

    bool isKeyword( const Bu::String &sStr );
    bool isCond( const Bu::String &sStr );
    void include( const Bu::String &sStr, void *scanner, YYLTYPE *loc );
    void endInclude( YYLTYPE *loc );

    void error( int iLine1, int iLine2, int iCol1, int iCol2,
        const Bu::String &sMsg );

    class Ast &xAst;

    void addIncludePath( const Bu::String &sPath );

private:
    Bu::Stack<Bu::String> sFilename;
    Bu::Stack<YYLTYPE> sLocation;
    StrList lIncludePaths;
    Bu::Hash<Bu::String, bool> hConds;
};

#define YY_DECL int build_lex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, BuildParser &b )
YY_DECL;

#endif