<commit_before>#!/usr/bin/tclsh

# Copyright 2019 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# Optional parameter to provide an output directory
set DEST_DIR "."
if [regexp {out_dir=([a-zA-Z0-9_/\.-:]+)} $argv tmp DEST_DIR] {}

set LISTENERS                 "Parser PreProc"

set ANTLR_DEFINITION(Parser)  "parser/SV3_1aParserBaseListener.h"
set CPP_INPUT(Parser)         "SourceCompile/SV3_1aTreeShapeListener.cpp"
set HEADER_OUTPUT(Parser)     "SourceCompile/SV3_1aTreeShapeListener.h"

set ANTLR_DEFINITION(PreProc) "parser/SV3_1aPpParserBaseListener.h"
set CPP_INPUT(PreProc)        "SourceCompile/SV3_1aPpTreeShapeListener.cpp"
set HEADER_OUTPUT(PreProc)    "SourceCompile/SV3_1aPpTreeShapeListener.h"

set VOBJECTTYPES_CPP_BASENAME "SourceCompile/VObjectTypes"
set VOBJECTTYPES_PY_H         "API/vobjecttypes_py.h"

puts "Outputting stuff e.g. to ${VOBJECTTYPES_CPP_BASENAME}"

proc generate_header { listener } {
    global LISTENERS ANTLR_DEFINITION HEADER_OUTPUT CPP_INPUT TYPES DEST_DIR

    set oid [open "${DEST_DIR}/$HEADER_OUTPUT($listener)" "w"]

    # Read .cpp hand written methods
    set cid [open $CPP_INPUT($listener)]
    set cpp_spec "[read $cid]"
    close $cid
    set lines [split $cpp_spec "\n"]
    foreach line $lines {
      if {[regexp {::(enter[a-zA-Z0-9_]+)} $line tmp method] || [regexp {::(exit[a-zA-Z0-9_]+)} $line tmp method] || [regexp {::(visit[a-zA-Z0-9_]+)} $line tmp method]} {
          set CUSTOM_METHOD($method) 1
      }
    }<commit_msg>Swap position of colon ':' and minus '-' in regex to make kokoro system happy.<commit_after>#!/usr/bin/tclsh

# Copyright 2019 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# Optional parameter to provide an output directory
set DEST_DIR "."
if [regexp {out_dir=([a-zA-Z0-9_/\.:-]+)} $argv tmp DEST_DIR] {}

set LISTENERS                 "Parser PreProc"

set ANTLR_DEFINITION(Parser)  "parser/SV3_1aParserBaseListener.h"
set CPP_INPUT(Parser)         "SourceCompile/SV3_1aTreeShapeListener.cpp"
set HEADER_OUTPUT(Parser)     "SourceCompile/SV3_1aTreeShapeListener.h"

set ANTLR_DEFINITION(PreProc) "parser/SV3_1aPpParserBaseListener.h"
set CPP_INPUT(PreProc)        "SourceCompile/SV3_1aPpTreeShapeListener.cpp"
set HEADER_OUTPUT(PreProc)    "SourceCompile/SV3_1aPpTreeShapeListener.h"

set VOBJECTTYPES_CPP_BASENAME "SourceCompile/VObjectTypes"
set VOBJECTTYPES_PY_H         "API/vobjecttypes_py.h"

puts "Outputting stuff e.g. to ${VOBJECTTYPES_CPP_BASENAME}"

proc generate_header { listener } {
    global LISTENERS ANTLR_DEFINITION HEADER_OUTPUT CPP_INPUT TYPES DEST_DIR

    set oid [open "${DEST_DIR}/$HEADER_OUTPUT($listener)" "w"]

    # Read .cpp hand written methods
    set cid [open $CPP_INPUT($listener)]
    set cpp_spec "[read $cid]"
    close $cid
    set lines [split $cpp_spec "\n"]
    foreach line $lines {
      if {[regexp {::(enter[a-zA-Z0-9_]+)} $line tmp method] || [regexp {::(exit[a-zA-Z0-9_]+)} $line tmp method] || [regexp {::(visit[a-zA-Z0-9_]+)} $line tmp method]} {
          set CUSTOM_METHOD($method) 1
      }
    }
{'fraction_non_alphanumeric': 0.11023427866831073, 'fraction_numerical': 0.014303329223181258, 'mean_word_length': 4.1668789808917195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5620574', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1360, 'n_words': 388}