<commit_before>#!/usr/bin/env python3
#-
# Copyright (c) 2006 Verdens Gang AS
# Copyright (c) 2006-2014 Varnish Software AS
# All rights reserved.
#
# Author: <NAME> <<EMAIL>>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Generate various .c and .h files for the VCL compiler and the interfaces
# for it.

#######################################################################
# These are our tokens

# We could drop all words such as "include", "if" etc, and use the
# ID type instead, but declaring them tokens makes them reserved words
# which hopefully makes for better error messages.
# XXX: does it actually do that ?

import sys

srcroot = "../.."
buildroot = "../.."
if len(sys.argv) == 3:
	srcroot = sys.argv[1]
	buildroot = sys.argv[2]

tokens = {
	"T_INC":	"++",
	"T_DEC":	"--",
	"T_CAND":	"&&",
	"T_COR":	"||",
	"T_LEQ":	"<=",
	"T_EQ":		"==",
	"T_NEQ":	"!=",
	"T_GEQ":	">=",
	"T_SHR":	">>",
	"T_SHL":	"<<",
	"T_INCR":	"+=",
	"T_DECR":	"-=",
	"T_MUL":	"*=",
	"T_DIV":	"/=",
	"T_NOMATCH":	"!~",

	# Single char tokens, for convenience on one line
	None:		"{}()*+-/%><=;!&.|~,",

	# These have handwritten recognizers
	"ID":		None,
	"CNUM":		None,
	"CSTR":		None,
	"EOI":		None,
	"CSRC":		None,
}

#######################################################################
# Our methods and actions

returns =(

	###############################################################
	# Client side

	('recv',
		"C",
		('synth', 'pass', 'pipe', 'hash', 'purge',)
	),
	('pipe',
		"C",
		('synth', 'pipe',)
	),
	('pass',
		"C",
		('synth', 'restart', 'fetch',)
	),
	('hash',
		"C",
		('lookup',)
	),
	('purge',
		"C",
		('synth', 'restart',)
	),
	('miss',
		"C",
		('synth', 'restart', 'pass', 'fetch',)
	),
	('hit',
		"C",
		('synth', 'restart', 'pass', 'fetch', 'deliver',)
	),
	('deliver',
		"C",
		('synth', 'restart', 'deliver',)
	),
	('synth',
		"C",
		('restart', 'deliver',)
	),

	###############################################################
	# Backend-fetch

	('backend_fetch',
		"B",
		('fetch', 'abandon')
	),
	('backend_response',
		"B",
		('deliver', 'retry', 'abandon')
	),
	('backend_error',
		"B",
		('deliver', 'retry')
	),

	###############################################################
	# Housekeeping

	('init',
		"",
		('ok',)
	),
	('fini',
		"",
		('ok',)
	),
)

#######################################################################
# Variables available in sessions
#
# 'all' means all methods
# 'client' means all methods tagged "C"
# 'backend' means all methods tagged "B"
# 'both' means all methods tagged "B" or "C"

sp_variables = [
	('client.ip',
		'IP',
		( 'client',),
		( ), """
		The client's IP address.
		"""
	),
	('client.identity',
		'STRING',
		( 'client',),
		( 'client',), """
		Identification of the client, used to load balance
		in the client director.
		"""
	),
	('server.ip',
		'IP',
		( 'client',),
		( ), """
		The IP address of the socket on which the client
		connection was received.
		"""
	),
	('server.hostname',
		'STRING',
		( 'client',),
		( ), """
		The host name of the server.
		"""
	),
	('server.identity',
		'STRING',
		( 'client',),
		( ), """
		The identity of the server, as set by the -i
		parameter.  If the -i parameter is not passed to varnishd,
		server.identity will be set to the name of the instance, as<commit_msg>Oops, forgot this bit of previous commit<commit_after>#!/usr/bin/env python3
#-
# Copyright (c) 2006 Verdens Gang AS
# Copyright (c) 2006-2014 Varnish Software AS
# All rights reserved.
#
# Author: <NAME> <ph<EMAIL>>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Generate various .c and .h files for the VCL compiler and the interfaces
# for it.

#######################################################################
# These are our tokens

# We could drop all words such as "include", "if" etc, and use the
# ID type instead, but declaring them tokens makes them reserved words
# which hopefully makes for better error messages.
# XXX: does it actually do that ?

import sys

srcroot = "../.."
buildroot = "../.."
if len(sys.argv) == 3:
	srcroot = sys.argv[1]
	buildroot = sys.argv[2]

tokens = {
	"T_INC":	"++",
	"T_DEC":	"--",
	"T_CAND":	"&&",
	"T_COR":	"||",
	"T_LEQ":	"<=",
	"T_EQ":		"==",
	"T_NEQ":	"!=",
	"T_GEQ":	">=",
	"T_SHR":	">>",
	"T_SHL":	"<<",
	"T_INCR":	"+=",
	"T_DECR":	"-=",
	"T_MUL":	"*=",
	"T_DIV":	"/=",
	"T_NOMATCH":	"!~",

	# Single char tokens, for convenience on one line
	None:		"{}()*+-/%><=;!&.|~,",

	# These have handwritten recognizers
	"ID":		None,
	"CNUM":		None,
	"CSTR":		None,
	"EOI":		None,
	"CSRC":		None,
}

#######################################################################
# Our methods and actions

returns =(

	###############################################################
	# Client side

	('recv',
		"C",
		('synth', 'pass', 'pipe', 'hash', 'purge',)
	),
	('pipe',
		"C",
		('synth', 'pipe',)
	),
	('pass',
		"C",
		('synth', 'restart', 'fetch',)
	),
	('hash',
		"C",
		('lookup',)
	),
	('purge',
		"C",
		('synth', 'restart',)
	),
	('miss',
		"C",
		('synth', 'restart', 'pass', 'fetch',)
	),
	('hit',
		"C",
		('synth', 'restart', 'pass', 'fetch', 'deliver',)
	),
	('deliver',
		"C",
		('synth', 'restart', 'deliver',)
	),
	('synth',
		"C",
		('restart', 'deliver',)
	),

	###############################################################
	# Backend-fetch

	('backend_fetch',
		"B",
		('fetch', 'abandon')
	),
	('backend_response',
		"B",
		('deliver', 'retry', 'abandon')
	),
	('backend_error',
		"B",
		('deliver', 'retry')
	),

	###############################################################
	# Housekeeping

	('init',
		"",
		('ok',)
	),
	('fini',
		"",
		('ok',)
	),
)

#######################################################################
# Variables available in sessions
#
# 'all' means all methods
# 'client' means all methods tagged "C"
# 'backend' means all methods tagged "B"
# 'both' means all methods tagged "B" or "C"

sp_variables = [
	('client.ip',
		'IP',
		( 'client',),
		( ), """
		The client's IP address.
		"""
	),
	('client.identity',
		'STRING',
		( 'client',),
		( 'client',), """
		Identification of the client, used to load balance
		in the client director.
		"""
	),
	('server.ip',
		'IP',
		( 'client',),
		( ), """
		The IP address of the socket on which the client
		connection was received.
		"""
	),
	('server.hostname',
		'STRING',
		( 'all',),
		( ), """
		The host name of the server.
		"""
	),
	('server.identity',
		'STRING',
		( 'all',),
		( ), """
		The identity of the server, as set by the -i
		parameter.  If the -i parameter is not passed to varnishd,
		server.identity will be set to the name of the instance, as
{'fraction_non_alphanumeric': 0.2512990602542841, 'fraction_numerical': 0.003980099502487562, 'mean_word_length': 4.107848673066064, 'pattern_counts': {'":': 40, '<': 17, '<?xml version=': 0, '>': 17, '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': '2321524', 'n_tokens_mistral': 3303, 'n_tokens_neox': 3008, 'n_words': 985}