"checkit_tiff" is an incredibly fast conformance checker for baseline TIFFs (with various extensions), see http://andreas-romeyke.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
7.9 KiB

# rule based checks if given TIFF is a specific baseline TIFF
#
# author: Andreas Romeyke, 2015
# licensed under conditions of libtiff
# (see http://libtiff.maptools.org/misc.html)
#
start <- ( Line )+ EndOfFile
Line <- Comment { incrlineno(); commentline(); }
/ SpaceLine { incrlineno(); }
/ Tagline { incrlineno(); tagline(); }
/ < MiscUntilEOL > { set_parse_error("wrong line entry",yytext); }
Comment <- '#' ( !EndOfLine . )* EndOfLine
Tagline <- Tag Semicolon Requirements Semicolon Values EndOfLine { rule_addtag_config(); }
/ Tag Semicolon Requirements Semicolon Values { set_parse_error( "tagline requires EOL", yytext); }
/ Tag Semicolon Requirements Semicolon { set_parse_error("tagline requires values", yytext); }
/ Tag Semicolon Requirements { set_parse_error("tagline expects missed semicolon here", yytext); }
/ Tag Semicolon { set_parse_error("tagline requires a requiemrent-keyword (mandatory, etc.)",yytext); }
/ Tag { set_parse_error("tagline expects missed semicolon here", yytext); }
Tag <- < ( Digit )+ > {
int tag = atoi(yytext);
/* rule_tagorder_in_dsl( tag ); */
settag( tag );
}
/ < MiscUntilEOL > { set_parse_error("wrong tag", yytext);}
TagReference <- Number
/ < MiscUntilEOL > { set_parse_error("wrong tagreference", yytext); }
Semicolon <- ';' ( Space )*
/ < MiscUntilEOL > { set_parse_error("missed semicolon", yytext);}
Requirements <- 'mandatory' { set_mandatory(); }
/ IfDepends { set_ifdepends(); }
/ OptDepends { set_optdepends(); }
/ 'optional' { set_optional(); }
/ < MiscUntilEOL > { set_parse_error("wrong requirements-keyword", yytext);}
IfDepends <- 'depends' OpenBracket TagReference Dot ValueReference ClosingBracket
/ 'depends' OpenBracket TagReference Dot ValueReference { set_parse_error("requirement expects a closing bracket", yytext); }
/ 'depends' OpenBracket TagReference Dot { set_parse_error("requirement expects a value reference", yytext); }
/ 'depends' OpenBracket TagReference { set_parse_error("requirement expects a dot", yytext); }
/ 'depends' OpenBracket { set_parse_error("requirement expects a tagreference", yytext); }
/ 'depends' { set_parse_error("requirement expects an open bracket", yytext); }
OptDepends <- 'optdepends' OpenBracket TagReference Dot ValueReference ClosingBracket
/ 'optdepends' OpenBracket TagReference Dot ValueReference { set_parse_error("requirement expects a closing bracket", yytext); }
/ 'optdepends' OpenBracket TagReference Dot { set_parse_error("requirement expects a value reference", yytext); }
/ 'optdepends' OpenBracket TagReference { set_parse_error("requirement expects a dot", yytext); }
/ 'optdepends' OpenBracket { set_parse_error("requirement expects a tagreference", yytext); }
/ 'optdepends' { set_parse_error("requirement expects an open bracket", yytext); }
Values <- Any
/ Range
/ LogicalOr
/ Only
/ RegEx
/ < MiscUntilEOL > { set_parse_error("wrong values-keyword", yytext);}
Range <- 'range' OpenBracket Number Colon Number ClosingBracket {set_range(); }
/ 'range' OpenBracket Number Colon Number { set_parse_error("values expects a closing bracket", yytext); }
/ 'range' OpenBracket Number Colon { set_parse_error("values expects a number", yytext); }
/ 'range' OpenBracket Number { set_parse_error("values expects a colon", yytext); }
/ 'range' OpenBracket { set_parse_error("values expects a number", yytext); }
/ 'range' { set_parse_error("values expects an open bracket", yytext); }
Number <- < ( Digit )+ > { i_push(atol(yytext) );}
/ < MiscUntilEOL > { set_parse_error("number expected", yytext);}
Colon <- ',' (Space )*
/ < MiscUntilEOL > { set_parse_error("missed colon", yytext);}
Dot <- '.' (Space )*
/ < MiscUntilEOL > { set_parse_error("missed dot", yytext)}
OpenBracket <- '('
/ < MiscUntilEOL > { set_parse_error("missed open bracket", yytext); }
ClosingBracket <- ')'
/ < MiscUntilEOL > { set_parse_error("missed closing bracket", yytext); }
LogicalOr <- 'logical_or' OpenBracket ValueList ClosingBracket { set_logical_or(); }
/ 'logical_or' OpenBracket ValueList { set_parse_error("values expects a closing bracket", yytext);}
/ 'logical_or' OpenBracket { set_parse_error("values expects a value list", yytext);}
/ 'logical_or' { set_parse_error("values expects an open bracket", yytext);}
ValueList <- Value (Colon Value)*
Value <- Number { incr_values(); }
ValueReference <- 'any' { set_any_reference(); }
/ Number
# / String
/ < MiscUntilEOL > { set_parse_error("value reference error: '%s'", yytext);}
Only <- 'only' OpenBracket ValueList ClosingBracket { set_only(); }
/ 'only' OpenBracket ValueList { set_parse_error("values expects a closing bracket", yytext);}
/ 'only' OpenBracket { set_parse_error("values expects a value list", yytext);}
/ 'only' { set_parse_error("values expects an open bracket", yytext);}
RegEx <- 'regex' OpenBracket '"' < ( PCRE )* > '"' ClosingBracket { set_regex( yytext ); }
/ 'regex' OpenBracket '"' < ( PCRE )* > '"' { set_parse_error("expects a closing bracket", yytext); }
/ 'regex' OpenBracket '"' < ( PCRE )* > { set_parse_error("expects a closing '\"'", yytext); }
/ 'regex' OpenBracket '"' { set_parse_error("expects a PCRE-regex", yytext); }
/ 'regex' OpenBracket { set_parse_error("expects an open '\"'", yytext); }
/ 'regex' { set_parse_error("expects an open bracket", yytext); }
SpaceLine <- Space? EndOfLine
Space <- ' ' / '\t'
Any <- 'any' { set_any(); }
Digit <- [0-9]
#String <- '"' < ( [A-Za-z0-9- :] )* > '"' { s_push ( yytext ); }
EndOfLine <- '\r\n' / '\n' / '\r'
EndOfFile <- !.
MiscUntilEOL <- ( [^\r\n]+ )
PCRE <- EscapedPCRE
/ [^"\\]
# FIXME: unescape char in yybuffer
EscapedPCRE <- '\\' '\\'
/ '\\' '"'