About general function
======================

The checkit-tool validates TIFF-files against a set of rules (see below). The
set of rules works as a whitelist. This means that TIFF tags that are used in
the file but not explicitly checked by a specific rule (not considering if
successful or not) are not allowed. In cases where a rule is executed only
if a predicate is set, the tag is only allowed if the predicate check succeeded.


Developers
==========
to configure the grammar you could use the PEG-extension for gvim from
https://github.com/gf3/peg.vim

To visualize the grammar, checkout this tools:

* http://bottlecaps.de/convert/
* http://bottlecaps.de/rr/ui

The actual grammar is visualized in grammar.xhtml

Users
=====
To define your own config-file for checking TIFFs, please use this simplified syntax:


* Each line is either a "modeline", an "include" line, a "tag" line, a comment or empty
* TODO: a modeline uses "mode(MODE)", MODE could be:
** "baseline", if no modeline is defined, it defaults to "mode(baseline)", too
** "extended"
* To include a configfile, use "include(FILENAME)", where FILENAME is a correct path
* Comments starts with '# '. They are only allowed to start right at the beginning of a new line.
* A tagline is built as "TAG; REQUIREMENTS; VALUES", where
* a TAG is an increasing number similar to TIFF-Tag numbers (see TIFF specification)
* REQUIREMENTS could be
** 'mandatory' - a tag must exist in TIFF
** 'optional' - a tag may exist in TIFF, if it does, it will be checked
** 'depends(REFERENCE)' - a tag must exist in TIFF if reference exists
** 'optdepends(REFERENCE)' - a tag may exists in TIFF if reference exists. If it exists it will be checked
* The syntax for a REFERENCE is TAGREFERENCE.VALUEREFERENCE
** TAGREFERENCE points to a tag number which must be exist,
** VALUEREFERENCE can be one of:
*** 'any' (which means any match) or
*** a decimal value or
*** 'range(START, END)', where START and END are decimal values
*** 'only(VALUE)', where VALUE is a decimal value
*** 'ntupel(VALUE, ..), decimal values as n-tupel enclosed in brackets
*** 'regex("REGEX")', where REGEX is a Perl compatible regular expression (PCRE) with escaped '"' and '\', it only works with tags of type ascii
** only if REFERENCE exists in TIFF the REQUIREMENTS rule will be checked
** The REQUIREMENTS rule will only be checked if REFERENCE exists in the TIF
file.
* VALUES can be one of:
** 'range(START, END)', where START and END are decimal values
** 'logical_or( VALUELIST)', where VALUELIST are comma-separated decimale values or ntupels
** 'any', which means any match
** 'only(VALUE)', where VALUE is a decimal value
** 'ntupel(VALUE, ..), decimal values as n-tupel enclosed in brackets
** 'regex("REGEX")', where REGEX is a Perl compatible regular expression (PCRE) with escaped '"' and '\', it only works with tags of type ascii
* each tagline or comment must be closed with a new line

If multiple rules are defined per tag, they will be combined.

For examples, please check the 'example_configs/' - directory.

Values
======

At the moment, the parser only supports a limited type of values. To make
handling easier, it uses only the value/offset part of an IFD entry.

Test if grammar parser works correctly
======================================

You could use the program '/checkit_check_config < your.cfg', this would print
a reversed stack output, how each rule will be applied.

For example, if your rule is

----
258; optdepends(262.1); logical_or(1, 4, 8)'
----

it will print:

----
((( parse config file )))
((( execute execution plan )))
((( clean execution plan )))
((( print internal execution plan )))

/* the rules are in stack order, the top comes first */

/* lineno=001 */ PRECOND: fc_tag_quiet tag=258 top i stack=(0)
/* lineno=001 */ PRECOND: fc_tag_has_value_quiet tag=262 top i stack=(1)
/* lineno=001 */ EXEC:    fc_internal_logic_combine_open tag=258 top i stack=(1)

/* lineno=001 */ EXEC:    fc_tag_has_value tag=258 top i stack=(1)

/* lineno=001 */ EXEC:    fc_tag_has_value tag=258 top i stack=(4)

/* lineno=001 */ EXEC:    fc_tag_has_value tag=258 top i stack=(8)

----

