Added comment support
This commit is contained in:
parent
e78371e26a
commit
f83c23b831
3 changed files with 42 additions and 18 deletions
3
README
3
README
|
|
@ -124,4 +124,5 @@ x single value x
|
||||||
* all possible values
|
* all possible values
|
||||||
|
|
||||||
|
|
||||||
Comments can be written inside {} by doing //=<COMMENT>
|
Comments can be done with //
|
||||||
|
note: // in value lines will not be ignored
|
||||||
|
|
|
||||||
26
example.mim
26
example.mim
|
|
@ -1,26 +1,29 @@
|
||||||
[
|
[
|
||||||
|
|
||||||
|
// LAUNCH CONTROL
|
||||||
{
|
{
|
||||||
name=Launch Control
|
name=Launch Control
|
||||||
commands=[
|
commands=[
|
||||||
|
// KNOBS HIGH
|
||||||
{
|
{
|
||||||
//=KNOB HA
|
//KNOB HA
|
||||||
//=displays value 0:127 for knobs 21-28
|
//displays value 0:127 for knobs 21-28
|
||||||
type=controller
|
type=controller
|
||||||
id=21:28
|
id=21:28
|
||||||
shell=echo "Knob #$id ch$channel:$value"
|
shell=echo "Knob #$id ch$channel:$value"
|
||||||
},
|
},
|
||||||
|
// KNOBS LOW
|
||||||
{
|
{
|
||||||
//=KNOB L1
|
//KNOB L1
|
||||||
//=displays value 0:127 for knob 41 from any channel
|
//displays value 0:127 for knob 41 from any channel
|
||||||
type=controller
|
type=controller
|
||||||
id=41
|
id=41
|
||||||
channel=*
|
channel=*
|
||||||
shell=echo "Knob #$id ch$channel:$value"
|
shell=echo "Knob #$id ch$channel:$value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//=KNOB L2
|
//KNOB L2
|
||||||
//=displays value -100:100 for knob 42 on channel 0
|
//displays value -100:100 for knob 42 on channel 0
|
||||||
type=controller
|
type=controller
|
||||||
id=42
|
id=42
|
||||||
channel=0
|
channel=0
|
||||||
|
|
@ -28,8 +31,8 @@
|
||||||
shell=echo "Knob #$id ch$channel:$value r:$rawvalue"
|
shell=echo "Knob #$id ch$channel:$value r:$rawvalue"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//=KNOB L3 H1
|
//KNOB L3 H1
|
||||||
//=displays value 0:1:0 for knob 42 on channel 1 (first half)
|
//displays value 0:1:0 for knob 42 on channel 1 (first half)
|
||||||
type=controller
|
type=controller
|
||||||
id=42
|
id=42
|
||||||
channel=1
|
channel=1
|
||||||
|
|
@ -39,8 +42,8 @@
|
||||||
shell=echo "Knob #$id ch$channel:$value"
|
shell=echo "Knob #$id ch$channel:$value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//=KNOB L3 H2
|
//KNOB L3 H2
|
||||||
//=displays value 0:1:0 for knob 42 on channel 1 (second half)
|
//displays value 0:1:0 for knob 42 on channel 1 (second half)
|
||||||
type=controller
|
type=controller
|
||||||
id=42
|
id=42
|
||||||
channel=1
|
channel=1
|
||||||
|
|
@ -52,15 +55,18 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
// LAUNCHPAD
|
||||||
{
|
{
|
||||||
name=Launchpad S
|
name=Launchpad S
|
||||||
commands=[
|
commands=[
|
||||||
{
|
{
|
||||||
|
// ANY NOTE ON
|
||||||
type=note
|
type=note
|
||||||
id=*
|
id=*
|
||||||
shell=echo "Note $id on velocity:$velocity"
|
shell=echo "Note $id on velocity:$velocity"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// ANY NOTE OFF
|
||||||
type=note
|
type=note
|
||||||
id=*
|
id=*
|
||||||
trigger=0
|
trigger=0
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ std::pair<std::string,std::string> readValue(std::string const& in, unsigned int
|
||||||
unsigned int i=0,j=0,reading=0;
|
unsigned int i=0,j=0,reading=0;
|
||||||
while(i<in.size())
|
while(i<in.size())
|
||||||
{
|
{
|
||||||
while(!isRead(in[i])) /*Lire jusqu'à un caractère lu (ingorer les espaces etc...)*/
|
while(!isRead(in[i])) //read till read char
|
||||||
i++;
|
i++;
|
||||||
if(i>=in.size())
|
if(i>=in.size())
|
||||||
{
|
{
|
||||||
|
|
@ -407,17 +407,26 @@ std::pair<std::string,std::string> readValue(std::string const& in, unsigned int
|
||||||
*rank=-1;
|
*rank=-1;
|
||||||
return std::make_pair("","");
|
return std::make_pair("","");
|
||||||
}
|
}
|
||||||
while(in[i]!='=' && in[i]!=':') //lire le nom
|
if(i+1 < in.size() && in[i]=='/' && in[i+1]=='/') //ignore // comment
|
||||||
|
{
|
||||||
|
i+=2;
|
||||||
|
while(i<in.size() && in[i] !='\n' )
|
||||||
|
i++;
|
||||||
|
i++;
|
||||||
|
while(!isRead(in[i]))
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while(in[i]!='=' && in[i]!=':') //read name
|
||||||
{
|
{
|
||||||
name += in[i];
|
name += in[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
if(occurence==reading) /*Si c'est l'occurence que l'on veut*/
|
if(occurence==reading) //this is the correct occurence
|
||||||
{
|
{
|
||||||
unsigned int counter=0;
|
unsigned int counter=0;
|
||||||
j=i;
|
j=i;
|
||||||
if(in[i]=='{') /*Valeur encapsulée*/
|
if(in[i]=='{') //encapsulated
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
while(i<in.size() && !(in[i]=='}' && counter==0))
|
while(i<in.size() && !(in[i]=='}' && counter==0))
|
||||||
|
|
@ -441,7 +450,7 @@ std::pair<std::string,std::string> readValue(std::string const& in, unsigned int
|
||||||
*rank=i;
|
*rank=i;
|
||||||
return std::make_pair(name, in.substr(j,i-j));
|
return std::make_pair(name, in.substr(j,i-j));
|
||||||
}
|
}
|
||||||
else if(in[i]=='[') /*Valeur encapsulée*/
|
else if(in[i]=='[') //encapsulated
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
while(i<in.size() && !(in[i]==']' && counter==0))
|
while(i<in.size() && !(in[i]==']' && counter==0))
|
||||||
|
|
@ -555,9 +564,17 @@ std::vector<std::string> readList(std::string const& in)
|
||||||
j=i;
|
j=i;
|
||||||
while(i<in.size() && !(in[i]==',' && counter==0) && !(in[i]==']' && counter==0) )
|
while(i<in.size() && !(in[i]==',' && counter==0) && !(in[i]==']' && counter==0) )
|
||||||
{
|
{
|
||||||
|
if(i+1 < in.size() && in[i]=='/' && in [i+1]=='/') //ignore // comments
|
||||||
|
{
|
||||||
|
i+=2;
|
||||||
|
while(i<in.size() && in[i] !='\n' )
|
||||||
|
i++;
|
||||||
|
i++;
|
||||||
|
j=i;
|
||||||
|
}
|
||||||
if(in[i]=='\\')
|
if(in[i]=='\\')
|
||||||
i++;
|
i++;
|
||||||
else if(in[i]=='{')
|
else if(in[i]=='{') // start of chunk
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
unsigned int counter2=0;
|
unsigned int counter2=0;
|
||||||
|
|
@ -572,7 +589,7 @@ std::vector<std::string> readList(std::string const& in)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(in[i]=='\"')
|
else if(in[i]=='\"') //quote value
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
while(in[i]!='\"')
|
while(in[i]!='\"')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue