forked from musescore/MuseScore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.h
119 lines (107 loc) · 3.79 KB
/
parser.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//=============================================================================
// BWW to MusicXML converter
// Part of MusE Score
// Linux Music Score Editor
// $Id: parser.h 4873 2011-10-19 19:33:04Z lvinken $
//
// Copyright (C) 2010 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef PARSER_H
#define PARSER_H
/**
\file
Definition of class Parser
*/
#include <QtCore/QList>
#include <QtCore/QString>
#include <QtCore/QVector>
#include "writer.h"
namespace Bww {
class Lexer;
struct NoteDescription
{
QString pitch;
QString beam;
QString type;
int dots;
bool tieStart;
bool tieStop;
StartStop triplet;
bool grace;
StartStop beamState;
QVector<BeamType> beamList;
NoteDescription(const QString _pitch, const QString _beam,
const QString _type, const int _dots,
bool _tieStart = false, bool _tieStop = false,
StartStop _triplet = ST_NONE,
bool _grace = false)
: pitch(_pitch), beam(_beam),
type(_type), dots(_dots),
tieStart(_tieStart), tieStop(_tieStop),
triplet(_triplet),
grace(_grace),
beamState(ST_NONE),
beamList(maxBeamLevel, BM_NONE)
{}
};
struct MeasureDescription
{
MeasureBeginFlags mbf;
QList<NoteDescription> notes;
MeasureEndFlags mef;
int duration;
MeasureDescription()
: duration(0)
{}
};
/**
The bww parser.
*/
class Parser
{
public:
Parser(Lexer& l, Writer& w);
void parse();
private:
void errorHandler(QString s);
void parseBar(Bww::MeasureEndFlags& mef);
void parseNote();
void parseGraces();
void parsePart(Bww::MeasureBeginFlags& mbf, Bww::MeasureEndFlags& mef);
void parseSeqNonNotes();
void parseSeqNotes();
void parseString();
void parseTempo();
void parseTSig();
Lexer& lex; ///< The lexer
Writer& wrt; ///< The writer
QString title; ///< Title read from the header
QString type; ///< Type read from the header
QString composer; ///< Composer read from the header
QString footer; ///< Footer read from the header
int tempo; ///< Tune tempo read from the header
int beat; ///< Beat type, read from the clef line
int beats; ///< Number of beats, read from the clef line
//bool inMeasure; ///< State: writing the notes in a measure
//int measureNr; ///< Current measure number
bool tieStart; ///< Tie start pending
bool inTie; ///< In a tie
bool tripletStart; ///< Triplet start pending
bool inTriplet; ///< In a triplet
QList<MeasureDescription> measures; ///< Parsed measures
bool tsigFound; ///< A valid time signature was found
};
} // namespace Bww
#endif // PARSER_H