#ifndef MML_PARSE_H_
#define MML_PARSE_H_
#include "stream.h"
// Used to keep track of the current state of a MML track
// and pass it around to the functions parsing the commands
typedef struct {
// MML track state
Stream *stream; // Pointer to stream data
Channel channel; // MML channel this belongs to
const char *ptr; // Pointer to next MML command
const char *endptr; // Pointer to end of track data
unsigned instrument; // Current instrument
unsigned length; // Current default length
unsigned octave; // Current octave
int transpose; // Current transpose
unsigned volume; // Current volume
unsigned slide: 1; // _ active (key-on becomes set pitch)
unsigned tie: 1; // & active (key-on/off becomes nothing)
// Used for error reporting
const char *start; // Pointer to start of this line
int line_num; // Current line number
int col_num; // Current column number
int basecol_num; // Start column number of this line
const char *filename; // MML file name
} MmlState;
int parse_mml_commands(Stream *stream, Channel channel, const char *filename);
int parse_mml_subloop(MmlState *mml_state);
int get_length(MmlState *mml_state, unsigned *result);
#endif