<commit_before>= tickly

A highly simplistic TCL parser and evaluator (primarily designed for parsing Nuke scripts)

== Contributing to tickly
 <commit_msg>And finally a decent README<commit_after>= 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

For example:
    
    p = Tickly::Parser.new
    
    p.parse '2' #=> ["2"]
    p.parse '{2 2}' #=> [[:c, "2", "2"]]
    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.

Lots and lots of TCL features are not supported - remember that most Nuke scripts are machine-generated.

== 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(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

== Contributing to tickly
 
{'fraction_non_alphanumeric': 0.07029795158286778, 'fraction_numerical': 0.008845437616387336, 'mean_word_length': 3.2808764940239046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1111616', 'n_tokens_mistral': 654, 'n_tokens_neox': 626, 'n_words': 291}