<commit_before>#!/usr/bin/tclsh
# Right-binding form of "const" is not permitted.
# Scan each sub-expression. If "const" is reached before an identifier
# then bail out

foreach f [getSourceFileNames] {
    set lineNo 1
    foreach line [getAllLines $f] {
        set caringAboutConst [expr 1]

        foreach t [getTokens $f $lineNo 0 [expr $lineNo + 1] -1 {const identifier leftparen}] {
            set type [lindex $t 3]

            # If we hit "const" and we 'care' about const, (eg, we're inside
            # a sub-expression and haven't yet hit an identifier) then bail
            # out here.
            if {$type == "const"} {
                if {$caringAboutConst == 1} {
                    report $f $lineNo "only left-binding form of 'const' is permitted"
                }
            }

            # If we hit an identifier, then we no longer care about const for
            # this sub-expression
            if {$type == "identifier"} {
                set caringAboutConst [expr 0]
            }

            # If we hit a leftparen, then we're in a new sub-expression and<commit_msg>Consider the built-in typenames too.<commit_after>#!/usr/bin/tclsh
# Right-binding form of "const" is not permitted.
# Scan each sub-expression. If "const" is reached before an identifier
# then bail out

foreach f [getSourceFileNames] {
    set lineNo 1
    foreach line [getAllLines $f] {
        set caringAboutConst [expr 1]
        set scanIdentifiers {const leftparen identifier unsigned int double float char bool auto}
        set typeIdentifiers {identifier unsigned int double float char bool auto}

        foreach t [getTokens $f $lineNo 0 [expr $lineNo + 1] -1 $scanIdentifiers] {
            set type [lindex $t 3]

            # If we hit "const" and we 'care' about const, (eg, we're inside
            # a sub-expression and haven't yet hit an identifier) then bail
            # out here.
            if {$type == "const"} {
                if {$caringAboutConst == 1} {
                    report $f $lineNo "only left-binding form of 'const' is permitted"
                }
            }

            # If we hit an type identifier, then we no longer care about
            # const this sub-expression
            foreach typeId $typeIdentifiers {
                if {$type == $typeId} {
                    set caringAboutConst [expr 0]
                }
            }

            # If we hit a leftparen, then we're in a new sub-expression and
{'fraction_non_alphanumeric': 0.08370400323493732, 'fraction_numerical': 0.00646987464617873, 'mean_word_length': 1.8634259259259258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4417512', 'n_tokens_mistral': 690, 'n_tokens_neox': 652, 'n_words': 280}