MuseScore  3.4
Music composition and notation
parser.h
Go to the documentation of this file.
1 //=============================================================================
2 // BWW to MusicXML converter
3 // Part of MusE Score
4 // Linux Music Score Editor
5 //
6 // Copyright (C) 2010 Werner Schweer and others
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License version 2.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //=============================================================================
20 
21 #ifndef PARSER_H
22 #define PARSER_H
23 
29 #include <QtCore/QList>
30 #include <QtCore/QString>
31 #include <QtCore/QVector>
32 
33 #include "writer.h"
34 
35 namespace Bww {
36 
37  class Lexer;
38 
40  {
41  QString pitch;
42  QString beam;
43  QString type;
44  int dots;
45  bool tieStart;
46  bool tieStop;
48  bool grace;
50  QVector<BeamType> beamList;
51  NoteDescription(const QString _pitch, const QString _beam,
52  const QString _type, const int _dots,
53  bool _tieStart = false, bool _tieStop = false,
54  StartStop _triplet = ST_NONE,
55  bool _grace = false)
56  : pitch(_pitch), beam(_beam),
57  type(_type), dots(_dots),
58  tieStart(_tieStart), tieStop(_tieStop),
59  triplet(_triplet),
60  grace(_grace),
61  beamState(ST_NONE),
62  beamList(maxBeamLevel, BM_NONE)
63  {}
64  };
65 
67  {
69  QList<NoteDescription> notes;
71  int duration;
73  : duration(0)
74  {}
75  };
76 
81  class Parser
82  {
83  public:
84  Parser(Lexer& l, Writer& w);
85  void parse();
86  private:
87  void errorHandler(QString s);
88  void parseBar(Bww::MeasureEndFlags& mef);
89  void parseNote();
90  void parseGraces();
91  void parsePart(Bww::MeasureBeginFlags& mbf, Bww::MeasureEndFlags& mef);
92  void parseSeqNonNotes();
93  void parseSeqNotes();
94  void parseString();
95  void parseTempo();
96  void parseTSig();
99  QString title;
100  QString type;
101  QString composer;
102  QString footer;
103  int tempo;
104  int beat;
105  int beats;
106  //bool inMeasure; ///< State: writing the notes in a measure
107  //int measureNr; ///< Current measure number
108  bool tieStart;
109  bool inTie;
111  bool inTriplet;
112  QList<MeasureDescription> measures;
113  bool tsigFound;
114  };
115 
116 } // namespace Bww
117 
118 #endif // PARSER_H
QString composer
Composer read from the header.
Definition: parser.h:101
QString pitch
Definition: parser.h:41
Writer & wrt
The writer.
Definition: parser.h:98
StartStop triplet
Definition: parser.h:47
bool tieStop
Definition: parser.h:46
QList< NoteDescription > notes
Definition: parser.h:69
QString type
Type read from the header.
Definition: parser.h:100
int beats
Number of beats, read from the clef line.
Definition: parser.h:105
Lexer & lex
The lexer.
Definition: parser.h:97
The flags that need to be handled at the beginning of a measure.
Definition: writer.h:53
Symbol type to text translation.
Definition: lexer.cpp:34
QString title
Title read from the header.
Definition: parser.h:99
bool tsigFound
A valid time signature was found.
Definition: parser.h:113
The flags that need to be handled at the end of a measure.
Definition: writer.h:72
int dots
Definition: parser.h:44
bool tripletStart
Triplet start pending.
Definition: parser.h:110
MeasureBeginFlags mbf
Definition: parser.h:68
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)
Definition: parser.h:51
int duration
Definition: parser.h:71
QString footer
Footer read from the header.
Definition: parser.h:102
bool grace
Definition: parser.h:48
Definition: symbols.h:53
Definition: parser.h:39
bool tieStart
Tie start pending.
Definition: parser.h:108
The bww parser.
Definition: parser.h:81
QString beam
Definition: parser.h:42
Definition of class Writer.
The bww lexer.
Definition: lexer.h:44
StartStop
Definition: symbols.h:51
bool inTriplet
In a triplet.
Definition: parser.h:111
QString type
Definition: parser.h:43
Definition: parser.h:66
Definition: writer.h:41
The writer that generates the output.
Definition: writer.h:91
bool tieStart
Definition: parser.h:45
QVector< BeamType > beamList
Definition: parser.h:50
int beat
Beat type, read from the clef line.
Definition: parser.h:104
StartStop beamState
Definition: parser.h:49
MeasureDescription()
Definition: parser.h:72
bool inTie
In a tie.
Definition: parser.h:109
MeasureEndFlags mef
Definition: parser.h:70
QList< MeasureDescription > measures
Parsed measures.
Definition: parser.h:112
int tempo
Tune tempo read from the header.
Definition: parser.h:103