= tickly A highly simplistic TCL parser and evaluator (primarily designed for parsing Nuke scripts). It structures the passed Nuke scripts into a TCL AST and return it. You can use some cheap tricks to discard the nodes you are not interested in. == Parsing Create a Parser object and pass TCL expressions/scripts to it. You can pass IO obejcts or strings. Note that parse() will always return an Array of expressions, even if you only fed it one expression line. For example: p = Tickly::Parser.new # One expression, even if it's invalid (2 is not a valid TCL bareword)- doesn't matter p.parse '2' #=> [["2"]] # TCL command p.parse "tail $list" #=> [["tail", "$list"]] # Multiple expressions p.parse "2\n2" #=> [["2"], ["2"]] # Expressions in curly braces p.parse '{2 2}' #=> [[:c, "2", "2"]] # Expressions in square brackets p.parse '{exec cmd [fileName]}' #=> [[:c, "exec", "cmd", [:b, "fileName"]]] The AST is represented by simple arrays. An array is a TCL expression. An array with the :c symbol at the beginning element is an expression in curly braces. An array with the :b symbol at the beginning represents an expression with string interpolations in it. If you are curious, :c stands for "curlies" and :b for "brackets". All the other array elements are guaranteed to be strings. Multiple expressions separated by ; or a newline will be accumulated as multiple arrays. Lots and lots of TCL features are not supported - remember that most Nuke scripts are machine-generated and they do not use most of the esoteric language features. == Evaulating Nuke uses the following syntax for it's nodes: SomeNode { someknob 15 anotherknob 3 andanother {curve x1 12 45 67} } and so on. You can use a simple Evaluator object to run through the nodes returned by the parser. To set up the evaulation you need to create classes matching the node classes by name. For example, a Blur class: class Blur def initialize(string_keyed_knobs_hash) end end e = Tickly::Evaluator.new e.add_node_handler_class Blur some_script_expressions = Tickly::Parser.new.parse(File.open("/mnt/raid/nuke/scripts/HugeShot_123.nk")) some_script_expressions.each do | expression_in_ast | # Everytime a Blur node is found in the script it will be instantiated, # and the knobs of the node will be passed to the constructor that you define e.evaluate(expression_in_ast) do | blur_node | # Now a Blur node instance is all yours end end == Animation curves You can parse Nuke's animation curves using Tickly::Curve. This will give you a way to iterate over every defined keyframe. == Contributing to tickly * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. * Fork the project. * Start a feature/bugfix branch. * Commit and push until you are happy with your contribution. * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. == Copyright Copyright (c) 2013 Julik Tarkhanov. See LICENSE.txt for further details.