iXno: scripting grammar for GeoGraphy


iXno (--> Ichno) is a micro language for GeoGraphy. It is intended as a fast and easy shortcut to control the graph structure and the dynamic process (i.e. the Graph and Runner instance). It does not exploit the potential of the Graph and the Runner classes and it sets many values with defaults.

Vertices and edges can be referred to respectively by label or vID and by vID.

Even if its typical use is to be input inside the NimChimpsky view or though a GeoDocument, you can nevertheless simply pass a command string to the parser through the .parse method, which is what the NimChimpsky view does.


a = Graph.new ;

b = Runner.new(a).gui ;

h = Sinusoider.new(b) ;

o = Painter.new(a, b, colFact:0.1); 

p = GraphParser(a, b, o).gui ;


// just like what you type in the NimChimpsky View

p.parse("e+ s90 1 s92 1 s94 1 s95 1 s90 a+ s95 t+ 480") ;



 This is the grammar that GraphParser can parse. 


v+ name dur name ... name

Add vertices with label name. Note that you cannot control x, y, vDur:  x and y are randomly chosen in a space 1200x800, while vDur is set to 0.


v- name name ... name

v- id id ... id

Remove vertices with label name or with vID id.


e+ name dur name ... name

Add edges having dur duration between successive vertices (names). 

If vertices do not exist, they are created (see before).


e- id id ... id

Remove edges with eID id


r+ name1 name2

Rename the label name1 in name2.


r+ vID1 vID2

Rename the vID1 in vID2.


i- name name ... name

i- id id ... id

Isolate each vertex (indicated by ID or by label) by removing all the edges in I/O.


c+ id dur

Change into dur the duration of the arch with eID id.


a+ name name ... name

a+ id id ... id

Add an actant on each vertex having label name or having vID id.


a- id id ... id

Remove all the actants with IDs id (Note that here id represent the actant IDs, not the vertices' one).


t+ bpm

Change the tempo to bpm.


s+ a

Prompt for a path and save the graph and the runner to a SC archive format file. Providing a name results in saving two files with names: name.run and name.gra. Set the current IOpath var.


s+

Save to the actual IOpath.


o+

Prompt for a path in order to open archive file. You have to choose the .run file and the realted .gra file must be available in the same folder.


w+

Clean all (reset data structures)



a = Graph.new ;

b = Runner.new(a, weight:0.02).gui(step:10) ; // gui can be excluded, indeed

h = Sinusoider.new(b) ; 

p = GraphParser(a, b) ;


// the following routine uses a GraphParser to control Graph and Runner

(

var i = 0, dur, label, n = 600 ;  


Routine.new({

n.do({ 

dur = 0.5.rand+0.5 ;

label = "s"++(60+(i*0.1)) ;

p.parse("e+"+label+dur+label+"p+"+label) ;

i = i+1;

0.1.rand.wait ;

}) ;

3.wait ;

n.do({ 

p.parse("a-"+(n-i).asString) ;

i = i-1;

0.1.rand.wait ;

}) ;


} ).play(AppClock)

)