[//000000001]: # (fileutil::magic::cgen \- file utilities) [//000000002]: # (Generated from file 'cgen\.man' by tcllib/doctools with format 'markdown') [//000000003]: # (fileutil::magic::cgen\(n\) 1\.2\.0 tcllib "file utilities")
[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]
# NAME fileutil::magic::cgen \- Generator core for compiler of magic\(5\) files # Table Of Contents - [Table Of Contents](#toc) - [Synopsis](#synopsis) - [Description](#section1) - [COMMANDS](#section2) - [Bugs, Ideas, Feedback](#section3) - [See Also](#seealso) - [Keywords](#keywords) - [Category](#category) # SYNOPSIS package require Tcl 8\.4 package require fileutil::magic::cgen ?1\.2\.0? package require fileutil::magic::rt ?1\.2\.0? package require struct::tree package require struct::list [__::fileutil::magic::cgen::2tree__ *script*](#1) [__::fileutil::magic::cgen::treedump__ *tree*](#2) [__::fileutil::magic::cgen::treegen__ *tree* *node*](#3) # DESCRIPTION This package provides the generator backend for a compiler of magic\(5\) files into recognizers based on the __[fileutil::magic::rt](rtcore\.md)__ recognizer runtime package\. For the compiler frontend using this generator see the package __[fileutil::magic::cfront](cfront\.md)__\. # COMMANDS - __::fileutil::magic::cgen::2tree__ *script* This command converts the recognizer specified by the *script* into a tree and returns the object command of that tree as its result\. It uses the package __[struct::tree](\.\./struct/struct\_tree\.md)__ for the tree\. The *script* is in the format specified by magic\(5\)\. - __::fileutil::magic::cgen::treedump__ *tree* This command takes a *tree* as generated by __::fileutil::magic::cgen::2tree__ and returns a string encoding the tree for human consumption, to aid in debugging\. - __::fileutil::magic::cgen::treegen__ *tree* *node* This command takes a *tree* as generated by __::fileutil::magic::cgen::2tree__ and returns a Tcl script, the recognizer for the file types represented by the sub\-tree rooted at the *node*\. The generated script makes extensive use of the commands provided by the recognizer runtime package __[fileutil::magic::rt](rtcore\.md)__ to perform its duties\. # Bugs, Ideas, Feedback This document, and the package it describes, will undoubtedly contain bugs and other problems\. Please report such in the category *fileutil :: magic* of the [Tcllib Trackers](http://core\.tcl\.tk/tcllib/reportlist)\. Please also report any ideas for enhancements you may have for either package and/or documentation\. When proposing code changes, please provide *unified diffs*, i\.e the output of __diff \-u__\. Note further that *attachments* are strongly preferred over inlined patches\. Attachments can be made by going to the __Edit__ form of the ticket immediately after its creation, and then using the left\-most button in the secondary navigation bar\. # SEE ALSO file\(1\), [fileutil](\.\./fileutil/fileutil\.md), magic\(5\) # KEYWORDS [file recognition](\.\./\.\./\.\./\.\./index\.md\#file\_recognition), [file type](\.\./\.\./\.\./\.\./index\.md\#file\_type), [file utilities](\.\./\.\./\.\./\.\./index\.md\#file\_utilities), [mime](\.\./\.\./\.\./\.\./index\.md\#mime), [type](\.\./\.\./\.\./\.\./index\.md\#type) # CATEGORY Programming tools