2012-06-06 14:38:28 +02:00
|
|
|
%code requires {
|
2012-05-31 16:04:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-09-07 10:27:31 +02:00
|
|
|
#include "i2-config.h"
|
2013-03-17 20:19:29 +01:00
|
|
|
#include "config/expression.h"
|
|
|
|
#include "config/expressionlist.h"
|
|
|
|
#include "config/configitembuilder.h"
|
|
|
|
#include "config/configcompiler.h"
|
|
|
|
#include "config/configcompilercontext.h"
|
|
|
|
#include "config/typerule.h"
|
|
|
|
#include "config/typerulelist.h"
|
|
|
|
#include "base/value.h"
|
2013-03-18 11:02:18 +01:00
|
|
|
#include "base/utility.h"
|
2013-03-17 20:19:29 +01:00
|
|
|
#include "base/array.h"
|
2013-03-16 21:18:53 +01:00
|
|
|
#include <sstream>
|
|
|
|
#include <stack>
|
|
|
|
#include <boost/smart_ptr/make_shared.hpp>
|
2013-03-18 11:02:18 +01:00
|
|
|
#include <boost/exception/diagnostic_information.hpp>
|
2012-05-31 16:04:51 +02:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2013-03-17 20:19:29 +01:00
|
|
|
#define YYLTYPE icinga::DebugInfo
|
2012-06-06 14:38:28 +02:00
|
|
|
|
|
|
|
}
|
2012-05-31 16:04:51 +02:00
|
|
|
|
2012-05-31 08:45:02 +02:00
|
|
|
%pure-parser
|
|
|
|
|
|
|
|
%locations
|
|
|
|
%defines
|
|
|
|
%error-verbose
|
|
|
|
|
2012-06-06 14:38:28 +02:00
|
|
|
%parse-param { ConfigCompiler *context }
|
2012-05-31 08:45:02 +02:00
|
|
|
%lex-param { void *scanner }
|
|
|
|
|
|
|
|
%union {
|
|
|
|
char *text;
|
2012-07-11 21:03:22 +02:00
|
|
|
double num;
|
2012-08-02 09:38:08 +02:00
|
|
|
icinga::Value *variant;
|
2012-06-01 16:49:33 +02:00
|
|
|
icinga::ExpressionOperator op;
|
2013-02-02 14:28:11 +01:00
|
|
|
icinga::TypeSpecifier type;
|
2012-05-31 08:45:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
%token <text> T_STRING
|
2013-02-01 22:44:58 +01:00
|
|
|
%token <text> T_STRING_ANGLE
|
2012-05-31 08:45:02 +02:00
|
|
|
%token <num> T_NUMBER
|
2012-06-01 16:49:33 +02:00
|
|
|
%token T_NULL
|
2012-05-31 16:04:51 +02:00
|
|
|
%token <text> T_IDENTIFIER
|
|
|
|
%token <op> T_EQUAL
|
|
|
|
%token <op> T_PLUS_EQUAL
|
|
|
|
%token <op> T_MINUS_EQUAL
|
|
|
|
%token <op> T_MULTIPLY_EQUAL
|
|
|
|
%token <op> T_DIVIDE_EQUAL
|
2013-02-02 14:28:11 +01:00
|
|
|
%token <type> T_TYPE_DICTIONARY
|
2013-03-14 12:17:46 +01:00
|
|
|
%token <type> T_TYPE_ARRAY
|
2013-02-02 14:28:11 +01:00
|
|
|
%token <type> T_TYPE_NUMBER
|
|
|
|
%token <type> T_TYPE_STRING
|
|
|
|
%token <type> T_TYPE_SCALAR
|
|
|
|
%token <type> T_TYPE_ANY
|
2013-02-06 00:32:05 +01:00
|
|
|
%token T_VALIDATOR
|
|
|
|
%token T_REQUIRE
|
|
|
|
%token T_ATTRIBUTE
|
2013-02-02 14:28:11 +01:00
|
|
|
%token T_TYPE
|
2012-05-31 08:45:02 +02:00
|
|
|
%token T_ABSTRACT
|
|
|
|
%token T_LOCAL
|
|
|
|
%token T_OBJECT
|
2013-02-16 09:18:34 +01:00
|
|
|
%token T_TEMPLATE
|
2012-05-31 08:45:02 +02:00
|
|
|
%token T_INCLUDE
|
2013-01-17 15:05:34 +01:00
|
|
|
%token T_LIBRARY
|
2012-05-31 08:45:02 +02:00
|
|
|
%token T_INHERITS
|
2013-02-02 14:28:11 +01:00
|
|
|
%token T_PARTIAL
|
2013-01-29 12:11:05 +01:00
|
|
|
%type <text> identifier
|
2013-03-14 12:17:46 +01:00
|
|
|
%type <variant> array
|
2012-06-01 16:49:33 +02:00
|
|
|
%type <variant> simplevalue
|
2012-05-31 16:04:51 +02:00
|
|
|
%type <variant> value
|
2012-06-01 16:49:33 +02:00
|
|
|
%type <variant> expressionlist
|
2013-02-02 14:28:11 +01:00
|
|
|
%type <variant> typerulelist
|
2012-05-31 16:04:51 +02:00
|
|
|
%type <op> operator
|
2013-02-02 14:28:11 +01:00
|
|
|
%type <type> type
|
|
|
|
%type <num> partial_specifier
|
2012-05-31 16:04:51 +02:00
|
|
|
%left '+' '-'
|
|
|
|
%left '*' '/'
|
2012-05-31 08:45:02 +02:00
|
|
|
%{
|
|
|
|
|
2012-05-31 08:59:40 +02:00
|
|
|
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
|
2012-05-31 08:45:02 +02:00
|
|
|
|
2012-08-07 21:02:12 +02:00
|
|
|
void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err)
|
2012-05-31 08:45:02 +02:00
|
|
|
{
|
2013-03-16 21:18:53 +01:00
|
|
|
std::ostringstream message;
|
2012-07-09 11:39:14 +02:00
|
|
|
message << *locp << ": " << err;
|
2013-02-06 12:51:12 +01:00
|
|
|
ConfigCompilerContext::GetContext()->AddError(false, message.str());
|
2012-05-31 08:45:02 +02:00
|
|
|
}
|
|
|
|
|
2012-06-06 14:38:28 +02:00
|
|
|
int yyparse(ConfigCompiler *context);
|
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
static std::stack<ExpressionList::Ptr> m_ExpressionLists;
|
|
|
|
static std::stack<Array::Ptr> m_Arrays;
|
2012-07-06 14:33:10 +02:00
|
|
|
static ConfigItemBuilder::Ptr m_Item;
|
2012-06-06 14:38:28 +02:00
|
|
|
static bool m_Abstract;
|
|
|
|
static bool m_Local;
|
2013-02-02 14:28:11 +01:00
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
static std::stack<TypeRuleList::Ptr> m_RuleLists;
|
2013-02-02 14:28:11 +01:00
|
|
|
static ConfigType::Ptr m_Type;
|
2012-05-31 10:16:32 +02:00
|
|
|
|
2012-06-06 14:38:28 +02:00
|
|
|
void ConfigCompiler::Compile(void)
|
2012-05-31 10:16:32 +02:00
|
|
|
{
|
2013-03-07 16:00:10 +01:00
|
|
|
ASSERT(ConfigCompilerContext::GetContext() != NULL);
|
2013-02-05 13:06:42 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
yyparse(this);
|
2013-03-16 21:18:53 +01:00
|
|
|
} catch (const std::exception& ex) {
|
2013-02-06 12:51:12 +01:00
|
|
|
ConfigCompilerContext::GetContext()->AddError(false, boost::diagnostic_information(ex));
|
2013-02-05 13:06:42 +01:00
|
|
|
}
|
2012-05-31 10:16:32 +02:00
|
|
|
}
|
|
|
|
|
2012-05-31 09:43:46 +02:00
|
|
|
#define scanner (context->GetScanner())
|
2012-05-31 08:45:02 +02:00
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%%
|
|
|
|
statements: /* empty */
|
|
|
|
| statements statement
|
|
|
|
;
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
statement: object | type | include | library
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
include: T_INCLUDE T_STRING
|
2012-07-02 10:29:32 +02:00
|
|
|
{
|
2013-02-03 01:41:00 +01:00
|
|
|
context->HandleInclude($2, false, yylloc);
|
2013-02-11 09:55:32 +01:00
|
|
|
free($2);
|
2013-02-01 22:44:58 +01:00
|
|
|
}
|
|
|
|
| T_INCLUDE T_STRING_ANGLE
|
|
|
|
{
|
2013-02-03 01:41:00 +01:00
|
|
|
context->HandleInclude($2, true, yylloc);
|
2013-02-11 09:55:32 +01:00
|
|
|
free($2);
|
2012-07-02 10:29:32 +02:00
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
|
2013-01-17 15:05:34 +01:00
|
|
|
library: T_LIBRARY T_STRING
|
|
|
|
{
|
|
|
|
context->HandleLibrary($2);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($2);
|
2013-01-17 15:05:34 +01:00
|
|
|
}
|
|
|
|
|
2013-01-29 12:11:05 +01:00
|
|
|
identifier: T_IDENTIFIER
|
|
|
|
| T_STRING
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2013-02-11 10:10:17 +01:00
|
|
|
free($1);
|
2013-01-29 12:11:05 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
type: partial_specifier T_TYPE identifier
|
|
|
|
{
|
|
|
|
String name = String($3);
|
2013-02-11 09:55:32 +01:00
|
|
|
free($3);
|
|
|
|
|
2013-02-05 13:06:42 +01:00
|
|
|
m_Type = ConfigCompilerContext::GetContext()->GetType(name);
|
2013-02-11 09:55:32 +01:00
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
if (!m_Type) {
|
|
|
|
if ($1)
|
2013-03-16 21:18:53 +01:00
|
|
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Partial type definition for unknown type '" + name + "'"));
|
2013-02-02 14:28:11 +01:00
|
|
|
|
|
|
|
m_Type = boost::make_shared<ConfigType>(name, yylloc);
|
2013-02-05 13:06:42 +01:00
|
|
|
ConfigCompilerContext::GetContext()->AddType(m_Type);
|
2013-02-02 14:28:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
type_inherits_specifier typerulelist
|
|
|
|
{
|
|
|
|
TypeRuleList::Ptr ruleList = *$6;
|
|
|
|
m_Type->GetRuleList()->AddRules(ruleList);
|
2013-02-06 00:32:05 +01:00
|
|
|
m_Type->GetRuleList()->AddRequires(ruleList);
|
|
|
|
|
|
|
|
String validator = ruleList->GetValidator();
|
|
|
|
if (!validator.IsEmpty())
|
|
|
|
m_Type->GetRuleList()->SetValidator(validator);
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
delete $6;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
partial_specifier: /* Empty */
|
|
|
|
{
|
|
|
|
$$ = 0;
|
|
|
|
}
|
|
|
|
| T_PARTIAL
|
|
|
|
{
|
|
|
|
$$ = 1;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
typerulelist: '{'
|
|
|
|
{
|
|
|
|
m_RuleLists.push(boost::make_shared<TypeRuleList>());
|
|
|
|
}
|
|
|
|
typerules
|
|
|
|
'}'
|
|
|
|
{
|
|
|
|
$$ = new Value(m_RuleLists.top());
|
|
|
|
m_RuleLists.pop();
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
typerules: typerules_inner
|
|
|
|
| typerules_inner ','
|
|
|
|
|
|
|
|
typerules_inner: /* empty */
|
|
|
|
| typerule
|
|
|
|
| typerules_inner ',' typerule
|
|
|
|
;
|
|
|
|
|
2013-02-06 00:32:05 +01:00
|
|
|
typerule: T_REQUIRE T_STRING
|
|
|
|
{
|
|
|
|
m_RuleLists.top()->AddRequire($2);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($2);
|
2013-02-06 00:32:05 +01:00
|
|
|
}
|
|
|
|
| T_VALIDATOR T_STRING
|
|
|
|
{
|
|
|
|
m_RuleLists.top()->SetValidator($2);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($2);
|
2013-02-06 00:32:05 +01:00
|
|
|
}
|
|
|
|
| T_ATTRIBUTE type T_STRING
|
2013-02-02 14:28:11 +01:00
|
|
|
{
|
2013-02-06 00:32:05 +01:00
|
|
|
TypeRule rule($2, $3, TypeRuleList::Ptr(), yylloc);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($3);
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
m_RuleLists.top()->AddRule(rule);
|
|
|
|
}
|
2013-02-06 00:32:05 +01:00
|
|
|
| T_ATTRIBUTE type T_STRING typerulelist
|
2013-02-02 14:28:11 +01:00
|
|
|
{
|
2013-02-06 00:32:05 +01:00
|
|
|
TypeRule rule($2, $3, *$4, yylloc);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($3);
|
2013-02-06 00:32:05 +01:00
|
|
|
delete $4;
|
2013-02-02 14:28:11 +01:00
|
|
|
m_RuleLists.top()->AddRule(rule);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
type_inherits_specifier: /* empty */
|
|
|
|
| T_INHERITS T_STRING
|
|
|
|
{
|
|
|
|
m_Type->SetParent($2);
|
2013-02-11 10:10:17 +01:00
|
|
|
free($2);
|
2013-02-02 14:28:11 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
type: T_TYPE_DICTIONARY
|
2013-03-14 12:17:46 +01:00
|
|
|
| T_TYPE_ARRAY
|
2013-02-02 14:28:11 +01:00
|
|
|
| T_TYPE_NUMBER
|
|
|
|
| T_TYPE_STRING
|
|
|
|
| T_TYPE_SCALAR
|
|
|
|
| T_TYPE_ANY
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-02-11 09:55:32 +01:00
|
|
|
object:
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
|
|
|
m_Abstract = false;
|
|
|
|
m_Local = false;
|
|
|
|
}
|
2013-02-16 09:18:34 +01:00
|
|
|
object_declaration identifier T_STRING
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
2012-07-06 14:33:10 +02:00
|
|
|
m_Item = boost::make_shared<ConfigItemBuilder>(yylloc);
|
2013-02-11 09:55:32 +01:00
|
|
|
|
2013-02-16 09:18:34 +01:00
|
|
|
m_Item->SetType($3);
|
|
|
|
free($3);
|
2013-02-11 09:55:32 +01:00
|
|
|
|
2013-02-16 09:18:34 +01:00
|
|
|
m_Item->SetName($4);
|
|
|
|
free($4);
|
2013-02-11 09:55:32 +01:00
|
|
|
|
2013-02-07 09:19:13 +01:00
|
|
|
m_Item->SetUnit(ConfigCompilerContext::GetContext()->GetUnit());
|
2012-06-01 16:49:33 +02:00
|
|
|
}
|
2013-02-02 14:28:11 +01:00
|
|
|
object_inherits_specifier expressionlist
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
2013-02-16 09:18:34 +01:00
|
|
|
ExpressionList::Ptr exprl = *$7;
|
|
|
|
delete $7;
|
2012-05-31 08:45:02 +02:00
|
|
|
|
2012-07-06 14:33:10 +02:00
|
|
|
m_Item->AddExpressionList(exprl);
|
|
|
|
m_Item->SetLocal(m_Local);
|
|
|
|
m_Item->SetAbstract(m_Abstract);
|
2012-06-01 16:49:33 +02:00
|
|
|
|
2013-02-05 13:06:42 +01:00
|
|
|
ConfigCompilerContext::GetContext()->AddItem(m_Item->Compile());
|
2012-07-06 14:33:10 +02:00
|
|
|
m_Item.reset();
|
2012-06-01 16:49:33 +02:00
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2013-02-16 09:18:34 +01:00
|
|
|
object_declaration: attributes T_OBJECT
|
|
|
|
| T_TEMPLATE
|
|
|
|
{
|
|
|
|
m_Abstract = true;
|
|
|
|
}
|
|
|
|
|
2012-06-01 16:49:33 +02:00
|
|
|
attributes: /* empty */
|
|
|
|
| attributes attribute
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
attribute: T_ABSTRACT
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
|
|
|
m_Abstract = true;
|
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
| T_LOCAL
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
|
|
|
m_Local = true;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
object_inherits_list: object_inherits_item
|
|
|
|
| object_inherits_list ',' object_inherits_item
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
object_inherits_item: T_STRING
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
2012-07-06 14:33:10 +02:00
|
|
|
m_Item->AddParent($1);
|
2012-06-06 14:38:28 +02:00
|
|
|
free($1);
|
2012-06-01 16:49:33 +02:00
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2013-02-02 14:28:11 +01:00
|
|
|
object_inherits_specifier: /* empty */
|
|
|
|
| T_INHERITS object_inherits_list
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2012-06-05 15:59:28 +02:00
|
|
|
expressionlist: '{'
|
2012-05-31 16:04:51 +02:00
|
|
|
{
|
2012-06-15 19:32:41 +02:00
|
|
|
m_ExpressionLists.push(boost::make_shared<ExpressionList>());
|
2012-05-31 16:04:51 +02:00
|
|
|
}
|
2012-06-01 16:49:33 +02:00
|
|
|
expressions
|
2012-06-05 15:59:28 +02:00
|
|
|
'}'
|
2012-05-31 16:04:51 +02:00
|
|
|
{
|
2012-08-02 09:38:08 +02:00
|
|
|
$$ = new Value(m_ExpressionLists.top());
|
2012-06-01 16:49:33 +02:00
|
|
|
m_ExpressionLists.pop();
|
2012-05-31 16:04:51 +02:00
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2012-06-29 10:39:36 +02:00
|
|
|
expressions: expressions_inner
|
|
|
|
| expressions_inner ','
|
|
|
|
|
|
|
|
expressions_inner: /* empty */
|
2012-06-01 16:49:33 +02:00
|
|
|
| expression
|
2012-06-29 10:39:36 +02:00
|
|
|
| expressions_inner ',' expression
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2013-01-29 12:11:05 +01:00
|
|
|
expression: identifier operator value
|
2012-05-31 16:04:51 +02:00
|
|
|
{
|
2012-06-06 14:38:28 +02:00
|
|
|
Expression expr($1, $2, *$3, yylloc);
|
2012-05-31 16:04:51 +02:00
|
|
|
free($1);
|
|
|
|
delete $3;
|
2012-06-01 16:49:33 +02:00
|
|
|
|
|
|
|
m_ExpressionLists.top()->AddExpression(expr);
|
|
|
|
}
|
2013-01-29 12:11:05 +01:00
|
|
|
| identifier '[' T_STRING ']' operator value
|
2012-06-01 16:49:33 +02:00
|
|
|
{
|
2012-06-06 14:38:28 +02:00
|
|
|
Expression subexpr($3, $5, *$6, yylloc);
|
2012-06-01 16:49:33 +02:00
|
|
|
free($3);
|
|
|
|
delete $6;
|
|
|
|
|
2012-06-15 19:32:41 +02:00
|
|
|
ExpressionList::Ptr subexprl = boost::make_shared<ExpressionList>();
|
2012-06-01 16:49:33 +02:00
|
|
|
subexprl->AddExpression(subexpr);
|
|
|
|
|
2012-06-06 14:38:28 +02:00
|
|
|
Expression expr($1, OperatorPlus, subexprl, yylloc);
|
|
|
|
free($1);
|
2012-06-01 16:49:33 +02:00
|
|
|
|
|
|
|
m_ExpressionLists.top()->AddExpression(expr);
|
|
|
|
}
|
2012-05-31 16:04:51 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
operator: T_EQUAL
|
|
|
|
| T_PLUS_EQUAL
|
|
|
|
| T_MINUS_EQUAL
|
|
|
|
| T_MULTIPLY_EQUAL
|
|
|
|
| T_DIVIDE_EQUAL
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
|
2013-03-14 12:17:46 +01:00
|
|
|
array: '['
|
|
|
|
{
|
|
|
|
m_Arrays.push(boost::make_shared<Array>());
|
|
|
|
}
|
|
|
|
array_items
|
|
|
|
']'
|
|
|
|
{
|
|
|
|
$$ = new Value(m_Arrays.top());
|
|
|
|
m_Arrays.pop();
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
array_items: array_items_inner
|
|
|
|
| array_items_inner ','
|
|
|
|
|
|
|
|
array_items_inner: /* empty */
|
|
|
|
| value
|
|
|
|
{
|
|
|
|
m_Arrays.top()->Add(*$1);
|
|
|
|
}
|
|
|
|
| array_items_inner ',' value
|
|
|
|
{
|
|
|
|
m_Arrays.top()->Add(*$3);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2012-06-01 16:49:33 +02:00
|
|
|
simplevalue: T_STRING
|
2012-05-31 16:04:51 +02:00
|
|
|
{
|
2012-08-02 09:38:08 +02:00
|
|
|
$$ = new Value($1);
|
2012-06-06 14:38:28 +02:00
|
|
|
free($1);
|
2012-05-31 16:04:51 +02:00
|
|
|
}
|
|
|
|
| T_NUMBER
|
|
|
|
{
|
2012-08-02 09:38:08 +02:00
|
|
|
$$ = new Value($1);
|
2012-05-31 16:04:51 +02:00
|
|
|
}
|
2012-06-01 16:49:33 +02:00
|
|
|
| T_NULL
|
|
|
|
{
|
2012-08-02 09:38:08 +02:00
|
|
|
$$ = new Value();
|
2012-06-01 16:49:33 +02:00
|
|
|
}
|
2013-03-14 12:17:46 +01:00
|
|
|
| array
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2012-06-01 16:49:33 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
value: simplevalue
|
|
|
|
| expressionlist
|
2012-05-31 16:04:51 +02:00
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2012-05-31 08:45:02 +02:00
|
|
|
;
|
|
|
|
%%
|