Functions

Parsing GMN files, strings and guido streams

Functions

GuidoParser * GuidoOpenParser ()
 Creates a new parser.
GuidoErrCode GuidoCloseParser (GuidoParser *p)
 Close a guido parser and releases all the associated ressources.
const char * GuidoGetStream (GuidoStream *gStream)
 returns the string of the GuidoStream
ARHandler GuidoFile2AR (GuidoParser *p, const char *file)
 Parse a file and create the corresponding AR.
ARHandler GuidoString2AR (GuidoParser *p, const char *str)
 Parse a string and create the corresponding AR.
ARHandler GuidoStream2AR (GuidoParser *p, GuidoStream *stream)
 Parse a GuidoStream and create the corresponding AR.
GuidoErrCode GuidoParserGetErrorCode (GuidoParser *p, int &line, int &col, const char **msg)
 Get the error syntax line/column.
GuidoStream * GuidoOpenStream ()
 Open a guido stream.
GuidoErrCode GuidoCloseStream (GuidoStream *s)
 Close a guido stream.
GuidoErrCode GuidoWriteStream (GuidoStream *s, const char *str)
 Write data to the stream.
GuidoErrCode GuidoResetStream (GuidoStream *s)
 Erase all stream content in order to reuse it.

Function Documentation

GuidoParser* GuidoOpenParser (  )

Creates a new parser.

Returns:
a guido parser.
GuidoErrCode GuidoCloseParser ( GuidoParser *  p )

Close a guido parser and releases all the associated ressources.

Parameters:
pa parser previously opened with GuidoOpenParser
Returns:
a Guido error code.
const char* GuidoGetStream ( GuidoStream *  gStream )

returns the string of the GuidoStream

Parameters:
gStreama GuidoStream
Returns:
a std::string.
ARHandler GuidoFile2AR ( GuidoParser *  p,
const char *  file 
)

Parse a file and create the corresponding AR.

Parameters:
pa parser previously opened with GuidoOpenParser
filethe file to parse.
Returns:
a ARHandler or 0 in case of error.
ARHandler GuidoString2AR ( GuidoParser *  p,
const char *  str 
)

Parse a string and create the corresponding AR.

Parameters:
pa parser previously opened with GuidoOpenParser
strthe string to parse.
Returns:
a ARHandler or 0 in case of error.
ARHandler GuidoStream2AR ( GuidoParser *  p,
GuidoStream *  stream 
)

Parse a GuidoStream and create the corresponding AR.

Parameters:
pa parser previously opened with GuidoOpenParser
streamthe GuidoStream to parse.
Returns:
a ARHandler or 0 in case of error.
GuidoErrCode GuidoParserGetErrorCode ( GuidoParser *  p,
int &  line,
int &  col,
const char **  msg 
)

Get the error syntax line/column.

Parameters:
pa parser previously opened with GuidoOpenParser
linea reference that will contain a line number in case of syntax error
cola reference that will contain a column number in case of syntax error
msga string that will contain the error message
Returns:
a Guido error code.
GuidoStream* GuidoOpenStream (  )

Open a guido stream.

Guido streams are intended to implement real-time input to the parser. In particular, streams allow to retrieve an AR in while the stream is still opened.

Returns:
a guido stream.
GuidoErrCode GuidoCloseStream ( GuidoStream *  s )

Close a guido stream.

Parameters:
sa GuidoStream
Returns:
a Guido error code.
GuidoErrCode GuidoWriteStream ( GuidoStream *  s,
const char *  str 
)

Write data to the stream.

Writing data to a stream may be viewed as writing gmn code by portion. Syntax errors concerning music/voice/tag/event/parameter non-closure won't be declared as such (GuidoWriteStream uses an automatic-closure mechanism). When a syntax error (other than a non-closure) occurs when writting data to the stream, the stream becomes invalid and should be closed. Further attempts to write data will always result in a syntax error.

Regarding syntax errors, allowed incomplete constructs are :

  • opened music i.e. { without closing }
  • opened voice i.e. [ without closing ]
  • opened range tag i.e. ( without closing )
  • opened range parameter i.e. < without closing > but with at least one parameter
  • opened chord i.e. ( without closing ) but with at least one note
    Note:
    for incomplete chords and range parameters, the ',' separator must always be followed by a note or a parameter. For example, don't write "{a," and then "b}" but "{a" and then ",b}".
    Parameters:
    sa GuidoStream previoulsy opened with GuidoOpenStream
    stra string containing a portion of gmn code
    Returns:
    a Guido error code.
GuidoErrCode GuidoResetStream ( GuidoStream *  s )

Erase all stream content in order to reuse it.

Parameters:
sa GuidoStream previoulsy opened with GuidoOpenStream
Returns:
a Guido error code.