Unformatted text preview:

m A language for music generation Language Reference Manual Yiling Hu yh2378 Monica Ramirez Santana mir2115 Jiaying Xu jx2129 Table of Contents Language Reference Manual 3 Introduction 3 Lexical Conventions 3 Tokens 3 Comments 3 Identifiers 3 Keywords 3 Literals 4 Identifiers 4 Scope 5 Types 5 Objects 6 Objects lvalues and rvalues 6 Promotion 6 Expressions 6 Primary Expressions 6 Postfix Expressions 7 Unary Operators 7 Multiplicative Operators 8 Additive Operators 8 Relational Operators 8 Equality Operators 9 Logical AND Operator 9 Logical OR Operator 9 Assignment Expressions 9 Declarations 10 Function Declarators 10 Array Declarators 10 Initialization 11 Statements 11 Compound Statement 12 Selection Statements 12 Iteration Statements 12 Function Definitions 12 Grammar 13 Appendix 16 scanner mll 16 parser mly 18 Language Reference Manual Introduction This manual describes the syntax for the m language a language for algorithmic music generation Lexical Conventions An m program consists of a single file with the syntax described in this document Tokens There are five types of tokens identifiers keywords operators literals and separators Spaces tabs and newlines collectively white space are ignored except when used as separators Separators are white space that is needed to separate otherwise adjacent identifiers keywords and pitch constants Comments as described below are also ignored If the input stream has been separated into tokens up to a given character the next token is the longest string of characters that could constitute a token Comments There are two methods to insert a comment 1 the characters introduce a comment which terminates with the characters 2 the characters introduce a comment which terminates at the following newline character Comments do not nest Identifiers An identifier is a sequence of letters including and digits the first character of which is a letter a z or A Z Identifiers may be of any length In identifiers upper and lowercase letters are different Keywords The following identifiers are reserved for the use as keywords and may not be used otherwise part int elseif staff float for note bool while chord if true void else false Literals There are four types of literals integer literals float literals Boolean literals and pitch literals literal integer literal floating literal boolean literal pitch literal Integer Literals An integer literal consists of a sequence of digits is always interpreted as a decimal number Floating Literals A floating literal consists of an integer part a decimal part and a fraction part integer fraction The integer and fraction parts both consist of a sequence of digits Either the integer part or the fraction part not both may be missing Pitch Literals A pitch literal is a sequence of characters and digits in one of the two formats outlined below Either note modifier opt octave note accepts the values a g and A G modifier accepts the values s f S F May be omitted octave accepts the values 0 9 Or The value r or R Examples of pitch constants As7 af7 A7 r Identifiers Identifiers are names that refer to functions and objects An object is a named region of storage and a variable is an identifier that refers to an object A variable has a scope and type A scope determines the lifetime of the storage associated with the variable The type indicates how the data contained at the storage location is interpreted Scope Scope is the region of the program in which a variable is known There are two kinds of scopes static and automatic The context of an object s declaration determines its scope Static variables are all variables that are defined outside of any blocks within the program Blocks are any segment of code encased in braces Automatic variables are all variables that are defined inside of a block Static variables are globally known Automatic variables are known inside of the block in which they are defined as well as all blocks contained within that block All variables are known within their scope only after their declaration Types There are four basic types void integer floating point and Boolean and six derived types note chord staff part function and array type void int float bool note chord staff part function array Basic Types The void type specifies an empty set of values and is denoted by the keyword void The integer type specifies a signed integer and is denoted by the keyword int The floating point type specifies a signed floating point number and is denoted by the keyword float The Boolean type specifies a truth value of either true or false and is denoted by the keyword bool Derived Types The note derived type contains three objects pitch duration and intensity The pitch object accepts pitch constants and integer values 0 128 default value is 128 The duration object accepts floating point values in the range 0 1 default value is 0 The intensity object accepts integer values 0 100 default value is 0 The chord derived type contains one object a collection of notes The staff derived type contains three objects BPM beat signature and a collection of notes and chords The BPM object accepts integer values 0 240 default value is 0 The beat signature object accepts floating point values in the range 0 1 default value is 0 The part derived type contains two objects instrument and a collection of staffs The instrument object accepts integer values 0 127 default value is 0 The array derived type contains objects of a given type The function derived type returns objects of a given type Objects Objects lvalues and rvalues An object also referred to as an rvalue is a named region of storage an lvalue is an expression referring to an object An obvious example of an lvalue expression is an identifier with suitable type and storage class The names lvalue and rvalue come from the assignment expression E1 E2 in which the left operand E1 must be an lvalue expression and the right operand E2 must be an rvalue expression Promotion Associating an object of type int with a float variable is allowable since m automatically promotes the int to a float if necessary Promotion occurs in all of the following cases 1 direct assignment of int to a float and 2 some arithmetic operations between int and float If an operation is being performed on two objects of which one operand is an int and the other is a float the evaluation of the expression is of type float if it cannot be rounded to an int otherwise the evaluation is of type int Demotion is not


View Full Document

Columbia COMS W4115 - m - A language for music generation

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Loading Unlocking...
Login

Join to view m - A language for music generation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view m - A language for music generation and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?