~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/parser/lomse_compiler.cpp

  • Committer: cecilios
  • Date: 2010-10-10 13:35:19 UTC
  • Revision ID: git-v1:2b333198c3033525d15763b84eaf79dac9fdab80
Preparing to use CMake. Updating with new code and missing files. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
//  You should have received a copy of the GNU General Public License along
14
14
//  with Lomse; if not, see <http://www.gnu.org/licenses/>.
15
15
//  
16
 
//  
17
 
//
18
16
//  For any comment, suggestion or feature request, please contact the manager of
19
17
//  the project at cecilios@users.sourceforge.net
20
18
//
46
44
    , m_pModelBuilder(mb)
47
45
    , m_pIdAssigner(ida)
48
46
    , m_pFinalTree(NULL)
49
 
    , m_pImDocument(NULL)
50
47
{
51
48
}
52
49
 
56
53
    , m_pModelBuilder( Injector::inject_ModelBuilder(documentScope) )
57
54
    , m_pIdAssigner( documentScope.id_assigner() )
58
55
    , m_pFinalTree(NULL)
59
 
    , m_pImDocument(NULL)
60
56
{
61
57
}
62
58
 
72
68
    }
73
69
}
74
70
 
75
 
ImoDocument* LdpCompiler::compile_file(const std::string& filename)
 
71
InternalModel* LdpCompiler::compile_file(const std::string& filename)
76
72
{
77
73
    m_pFinalTree = m_pParser->parse_file(filename);
78
74
    m_pIdAssigner->set_last_id( m_pParser->get_max_id() );
79
75
    return compile(m_pFinalTree);
80
76
}
81
77
 
82
 
ImoDocument* LdpCompiler::compile_string(const std::string& source)
 
78
InternalModel* LdpCompiler::compile_string(const std::string& source)
83
79
{
84
80
    m_pFinalTree = m_pParser->parse_text(source);
85
81
    m_pIdAssigner->set_last_id( m_pParser->get_max_id() );
86
82
    return compile(m_pFinalTree);
87
83
}
88
84
 
89
 
ImoDocument* LdpCompiler::create_empty()
 
85
InternalModel* LdpCompiler::create_empty()
90
86
{
91
87
    m_pFinalTree = parse_empty_doc();
92
88
    m_pIdAssigner->set_last_id( m_pParser->get_max_id() );
93
89
    return compile(m_pFinalTree);
94
90
}
95
91
 
96
 
ImoDocument* LdpCompiler::create_with_empty_score()
 
92
InternalModel* LdpCompiler::create_with_empty_score()
97
93
{
98
94
    m_pFinalTree = m_pParser->parse_text("(lenmusdoc (vers 0.0) (content (score (vers 1.6)(instrument (musicData)))))");
99
95
    m_pIdAssigner->set_last_id( m_pParser->get_max_id() );
100
96
    return compile(m_pFinalTree);
101
97
}
102
98
 
103
 
ImoDocument* LdpCompiler::compile(LdpTree* pParseTree)
 
99
InternalModel* LdpCompiler::compile(LdpTree* pParseTree)
104
100
{
105
101
    if (pParseTree->get_root()->is_type(k_score))
106
102
    {
110
106
    else
111
107
        m_pFinalTree = pParseTree;
112
108
 
113
 
    BasicModel* pBasicModel = m_pAnalyser->analyse_tree(m_pFinalTree);
114
 
    m_pImDocument = m_pModelBuilder->build_model(pBasicModel);
115
 
    return m_pImDocument;
 
109
    InternalModel* IModel = m_pAnalyser->analyse_tree(m_pFinalTree);
 
110
    m_pModelBuilder->build_model(IModel);
 
111
    return IModel;
116
112
}
117
113
 
118
114
LdpTree* LdpCompiler::wrap_score_in_lenmusdoc(LdpTree* pParseTree)
138
134
//LdpElement* LdpCompiler::create_element(const std::string& source)
139
135
//{
140
136
//    SpLdpTree tree = m_pParser->parse_text(source);
141
 
//    m_pBasicModel = m_pAnalyser->analyse_tree(tree);
142
 
//    delete m_pBasicModel;
143
 
//    m_pBasicModel = NULL;
 
137
//    m_IModel = m_pAnalyser->analyse_tree(tree);
 
138
//    delete m_IModel;
 
139
//    m_IModel = NULL;
144
140
//    return tree->get_root();
145
141
//}
146
142
//
147
 
//BasicModel* LdpCompiler::create_basic_model(const std::string& source)
 
143
//InternalModel* LdpCompiler::create_basic_model(const std::string& source)
148
144
//{
149
145
//    SpLdpTree tree = m_pParser->parse_text(source);
150
 
//    m_pBasicModel = m_pAnalyser->analyse_tree(tree);
 
146
//    m_IModel = m_pAnalyser->analyse_tree(tree);
151
147
//    delete tree->get_root();
152
 
//    return m_pBasicModel;
 
148
//    return m_IModel;
153
149
//}
154
150
 
155
151
int LdpCompiler::get_num_errors()