GraphParser a parser which translate a simple scripting language in SC for GeoGraphy

Inherits from: Object

The GraphParser is a parser for the GeoGraphy scripting grammar, Ixno. The basic idea was to have a control over GeoGraphy in the middle between code and buttons & sliders for live control. So the grammar has been conceived to be fast to type in a text field then to be evaluated and translated into the opportune SC commands.

Even if its origin lies in RT control from GUI element, it can be used with profit in "code" programming, by generating the opportune command strings. Command string are much more compressed than code, indeed.

See also: GeoGraphyGrammar

About vertex positioning

Actually when creating a new vertex with Ixno you get a random position, so that you have only to worry about the label. The idea is that while working in RT you're mainly interested in topology and you use the labels as a meaningful way to cope with vertices. The underlying positioning mechanism is based on the Layout class, which should be responsible for the position algorithms, so that you could be able to choose a specific algorithm for automatic x,y assignment. Now Layout implement only a uniform distribution in the 1200x800 space.

Creation / Class Methods

*new (graph, runner)

GraphParser.

graph - a graph. Default value is nil. .

runner - a runner. Default value is nil..

g = Graph.new ;

r = Runner.new(g).gui ;

p = GraphParser(g, r).gui ; // the gui method

Accessing Instance and Class Variables

iopath_(arg1)

iopath

A path where to save file. It is set while opening/saving a file the first time.

graph

The graph.

runner

The runner.

Functionality

The useful methods are substantially two.

parse (aString)

Parse the string and translate it into SC code.

aString - a string containing valid Ixno commands. Default value is nil. Other information.

(

var actual, previous ;

g = Graph.new ;

r = Runner.new(g) ;

q = GraphParser(g, r) ; // no GUI here

Squarer(r) ;

actual = "q"++(39).asString ;

q.parse("e+"+actual+1.asString+actual) ;

Routine.new({

var j, k ;

30.do({ arg i ;

j = i*[0.5, 1.5, 2.5].choose ; // n/4 tone scale

k = i+1 ;

previous = actual ;

actual = "q"++(40+j).asString ;

q.parse("e+"+actual+(1/k).asString+actual) ;

q.parse("e+"+actual+(1/k).asString+previous) ;

q.parse("e+"+previous+(1/k).asString+actual) ;

q.parse("p+"+actual) ;

rrand(0.2, 1.0).wait ;

}) ;

}).play(AppClock);

)

// to see the topology

p = Painter.new(g, r) ;

r.gui(step:27)

gui (step)

Create a GUI which can be used as a RT controller of different aspects.

The method also resizes the post window, renames it with a homage to Nim Chimpsky, changes the colors. It put together some functionalities of GeoDocument and GeoClock.

The top row contains:

server window: mirrors the server window:

chronometer: records the total timing since the GraphParser has been instantiated

tempo slider: allowing tempo setting (0-1000). If you want more use "t+" and the tempo as commands

At the bottom there is the

tex window: where you cain enter commands bith in SC and in iXno. Ctrl+P parse current line as iXno, Ctrl+Return evaluates current line as normal SC.

step - a multiplier fo GUI construction. Default value is 18. Better leave it so.

g = Graph.new ;

r = Runner.new(g).gui ;

p = GraphParser(g, r).gui(10) ; // smaller step

Examples

See before