require c-comment

syntax .coccinelle-meta

state decl code
    char -b A-Za-z_ ident
    char '"' string
    char / maybe-comment
    str @@ END meta-header
    eat this

state string
    char '"' decl string
    eat this

state maybe-comment comment
    char / line-comment
    char * .c-comment:decl
    recolor code 1
    noeat decl

state line-comment comment
    char "\n" decl
    eat this

state ident
    char -b a-zA-Z0-9_ this
    inlist keyword decl
    noeat decl

list keyword \
    fresh identifier metavariable field parameter type statement \
    declaration initialiser initializer local global idexpression \
    expression constant format assignment binary unary operator \
    position any symbol typedef attribute declarer iterator

syntax coccinelle

state line-start code
    char " \t\n" this
    char -b @ maybe-meta-header
    char + code added
    char -- - code removed
    noeat code

state code
    char "\n" line-start
    char / maybe-comment
    eat this

state maybe-comment comment
    char / line-comment
    char * .c-comment:code
    recolor code 1
    noeat code

state line-comment comment
    char "\n" line-start
    eat this

state maybe-meta-header code
    char -b @ meta-header
    char -bn "@\n" this
    eat line-start

state meta-header
    recolor meta-header
    noeat .coccinelle-meta:code

default keyword meta-keyword
default diff.header meta-header
default diff.added added
default diff.removed removed
