<commit_before>// This is the yacc input for creating the parser for interpolation
// expressions in Go.

// To build it:
//
// go tool yacc -p "expr" expr.y (produces y.go)
//

%{
package config

import (
	"fmt"
)

%}

%union {
	expr Interpolation
    str string
	variable InterpolatedVariable
	args []Interpolation
}

%type	<args> args
%type   <expr> expr
%type   <str> string
%type   <variable> variable

%token  <str> STRING IDENTIFIER
%token	<str> COMMA LEFTPAREN RIGHTPAREN

%%

top:
	expr
	{
		exprResult = $1
	}

expr:
	string
	{
		$$ = &LiteralInterpolation{Literal: $1}
	}
|	variable
	{
		$$ = &VariableInterpolation{Variable: $1}
	}
|	IDENTIFIER LEFTPAREN args RIGHTPAREN
	{
		f, ok := Funcs[$1]
		if !ok {
			exprErrors = append(exprErrors, fmt.Errorf(
				"Unknown function: %s", $1))
		}

		$$ = &FunctionInterpolation{Func: f, Args: $3}
	}

args:
	{
		$$ = nil
	}
|	expr COMMA expr
	{
		$$ = append($$, $1, $3)
	}
|	expr
	{
		$$ = append($$, $1)
	}

string:
	STRING
	{
		$$ = $1
	}

variable:
	IDENTIFIER
	{
		var err error
		$$, err = NewInterpolatedVariable($1)
		if err != nil {
			panic(err)<commit_msg>config: don't panic on parse error of variables<commit_after>// This is the yacc input for creating the parser for interpolation
// expressions in Go.

// To build it:
//
// go tool yacc -p "expr" expr.y (produces y.go)
//

%{
package config

import (
	"fmt"
)

%}

%union {
	expr Interpolation
    str string
	variable InterpolatedVariable
	args []Interpolation
}

%type	<args> args
%type   <expr> expr
%type   <str> string
%type   <variable> variable

%token  <str> STRING IDENTIFIER
%token	<str> COMMA LEFTPAREN RIGHTPAREN

%%

top:
	expr
	{
		exprResult = $1
	}

expr:
	string
	{
		$$ = &LiteralInterpolation{Literal: $1}
	}
|	variable
	{
		$$ = &VariableInterpolation{Variable: $1}
	}
|	IDENTIFIER LEFTPAREN args RIGHTPAREN
	{
		f, ok := Funcs[$1]
		if !ok {
			exprErrors = append(exprErrors, fmt.Errorf(
				"Unknown function: %s", $1))
		}

		$$ = &FunctionInterpolation{Func: f, Args: $3}
	}

args:
	{
		$$ = nil
	}
|	expr COMMA expr
	{
		$$ = append($$, $1, $3)
	}
|	expr
	{
		$$ = append($$, $1)
	}

string:
	STRING
	{
		$$ = $1
	}

variable:
	IDENTIFIER
	{
		var err error
		$$, err = NewInterpolatedVariable($1)
		if err != nil {
			exprErrors = append(exprErrors, fmt.Errorf(
				"Error parsing variable '%s': %s", $1, err))
{'fraction_non_alphanumeric': 0.15296610169491526, 'fraction_numerical': 0.009745762711864408, 'mean_word_length': 3.106086956521739, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2826058', 'n_tokens_mistral': 1008, 'n_tokens_neox': 951, 'n_words': 247}