~frankencode/drycore/trunk

« back to all changes in this revision

Viewing changes to dry/SyntaxState.cpp

  • Committer: Frank Mertens
  • Date: 2013-02-27 18:43:50 UTC
  • Revision ID: frank@cyblogic.de-20130227184350-ypu14rj5e2r8gwqz
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 /*
 
2
  * Copyright (C) 2007-2013 Frank Mertens.
 
3
  *
 
4
  * This program is free software; you can redistribute it and/or
 
5
  * modify it under the terms of the GNU General Public License
 
6
  * as published by the Free Software Foundation; either version
 
7
  * 2 of the License, or (at your option) any later version.
 
8
  */
 
9
 
 
10
#include "syntax.hpp"
 
11
#include "SyntaxState.hpp"
 
12
 
 
13
namespace dry
 
14
{
 
15
 
 
16
namespace syntax
 
17
{
 
18
 
 
19
State::State()
 
20
        : hint_(0),
 
21
          hintOffset_(-1)
 
22
{}
 
23
 
 
24
State::State(const DefinitionNode *definition, int numFlags, int numCaptures, State *parent)
 
25
        : definition_(definition),
 
26
          definitionId_(definition->id())
 
27
{
 
28
        flags_ = Flags::create(numFlags);
 
29
        captures_ = Captures::create(numCaptures);
 
30
        hint_ = 0;
 
31
        hintOffset_ = -1;
 
32
 
 
33
        if (parent) parent->child_ = this;
 
34
        for (int i = 0; i < flags_->length(); ++i) flags_->set(i, false);
 
35
        for (int i = 0; i < captures_->length(); ++i) captures_->set(i, Range::create());
 
36
}
 
37
 
 
38
bool State::flag(const char *name) const
 
39
{
 
40
        return flag(definition_->flagIdByName(name));
 
41
}
 
42
 
 
43
Range *State::capture(const char *name) const
 
44
{
 
45
        return capture(definition_->captureIdByName(name));
 
46
}
 
47
 
 
48
} // namespace syntax
 
49
 
 
50
} // namespace dry