Skip to content
Snippets Groups Projects
SQLPRefExp.y 1.72 KiB
%{
	#include "util.h"
%}

%define api.value.type {cons_cell *}
%token OR AND NOT LE AS DOT EQ

%token IDENTIFIER BY

%token ISA DISJOINT
%token FOREIGN KEY REFERENCES
%token COVERED FROM SELECT WHERE
%token EXISTS ALL INTCLASS STRCLASS OID REAL
%token INTEGER STRING SELF UNION
%token LIMIT DISTINCT REF

%token PATHFD TABLE WITH JOIN NOLIMIT

%start SQLPRefExp
%%
SQLPRefExp
	: RefExpTypeComponentList
	{
		$$ = create_cons_cell_w_atom("SQLP_REF_EXP", create_cons_cell(create_list("REF_EXP_TYPE_COMPONENT", $1), NULL));
		print_cons_tree($$);
	};

RefExpTypeComponentList
	: RefExpTypeComponent ';' RefExpTypeComponentList
	{
		$$ = create_cons_cell($1, $3);
	}
	| RefExpTypeComponent
	{
		$$ = create_cons_cell($1, NULL);
	};

RefExpTypeComponent
	: Guard REF AttributePathList
	{
		$$ = create_cons_cell_w_atom("REF_EXP_TYPE_COMPONENT", create_cons_cell($1, create_cons_cell(create_list("ATTRIBUTE_PATH", $3), NULL)));
	}
	| Guard REF '(' AttributePathList ')'
	{
		$$ = create_cons_cell_w_atom("REF_EXP_TYPE_COMPONENT", create_cons_cell($1, create_cons_cell(create_list("ATTRIBUTE_PATH", $4), NULL)));
	};

Guard
	: TableIdentifier
	{
		$$ = create_cons_cell_w_atom("GUARD", create_cons_cell($1, NULL));
	};

AttributePathList
	: AttributePath ',' AttributePathList
	{
		$$ = create_cons_cell(create_list("ATTRIBUTE", $1), $3);
	}
	| AttributePath
	{
		$$ = create_cons_cell(create_list("ATTRIBUTE", $1), NULL);
	};

AttributePath
	: AttributePath '.' AttributeIdentifier
	{
		$$ = create_cons_cell($3, $1);
	}
	| AttributeIdentifier
	{
		$$ = create_cons_cell($1, NULL);
	};

AttributeIdentifier
	: IDENTIFIER
	{
		$$ = create_identifier("ATTRIBUTE\0", identifier);
	}

TableIdentifier
	: IDENTIFIER
	{
		$$ = create_identifier("TABLE\0", identifier);
	};