Added dictionaries

master
Yevgen Muntyan 2006-03-07 21:02:01 -06:00
parent 4f52d191c6
commit 67ebf218ef
7 changed files with 990 additions and 286 deletions

View File

@ -62,7 +62,6 @@ ms_node_new (gsize node_size,
MSNode *node;
g_assert (node_size >= sizeof (MSNode));
g_assert (eval != NULL);
g_assert (type && type < MS_TYPE_NODE_LAST);
node = g_malloc0 (node_size);
@ -1342,3 +1341,232 @@ ms_node_break_new (MSBreakType type)
return node;
}
/****************************************************************************/
/* MSNodeDictElm
*/
static void
ms_node_dict_elm_destroy (MSNode *node_)
{
ms_node_unref (MS_NODE_DICT_ELM(node_)->dict);
g_free (MS_NODE_DICT_ELM(node_)->key);
}
static MSValue *
ms_node_dict_elm_eval (MSNode *node_,
MSContext *ctx)
{
MSValue *dict, *val;
MSNodeDictElm *node = MS_NODE_DICT_ELM (node_);
dict = _ms_node_eval (node->dict, ctx);
if (!dict)
return NULL;
if (dict->type != MS_VALUE_DICT)
{
ms_value_unref (dict);
return ms_context_format_error (ctx, MS_ERROR_VALUE,
"not a dict object");
}
val = ms_value_dict_get_elm (dict, node->key);
if (!val)
{
ms_value_unref (dict);
return ms_context_format_error (ctx, MS_ERROR_VALUE,
"no key '%s'", node->key);
}
ms_value_unref (dict);
return val;
}
MSNodeDictElm *
ms_node_dict_elm_new (MSNode *dict,
const char *key)
{
MSNodeDictElm *node;
g_return_val_if_fail (dict != NULL, NULL);
g_return_val_if_fail (key != NULL, NULL);
node = NODE_NEW (MSNodeDictElm,
MS_TYPE_NODE_DICT_ELM,
ms_node_dict_elm_eval,
ms_node_dict_elm_destroy);
node->dict = ms_node_ref (dict);
node->key = g_strdup (key);
return node;
}
/****************************************************************************/
/* MSNodeDictAssign
*/
static void
ms_node_dict_assign_destroy (MSNode *node_)
{
ms_node_unref (MS_NODE_DICT_ASSIGN(node_)->dict);
g_free (MS_NODE_DICT_ASSIGN(node_)->key);
ms_node_unref (MS_NODE_DICT_ASSIGN(node_)->val);
}
static MSValue *
ms_node_dict_assign_eval (MSNode *node_,
MSContext *ctx)
{
MSValue *dict = NULL, *val = NULL;
MSNodeDictAssign *node = MS_NODE_DICT_ASSIGN (node_);
dict = _ms_node_eval (node->dict, ctx);
if (!dict)
goto error;
val = _ms_node_eval (node->val, ctx);
if (!val)
goto error;
ms_value_dict_set_elm (dict, node->key, val);
ms_value_unref (dict);
return val;
error:
if (dict)
ms_value_unref (dict);
if (val)
ms_value_unref (val);
return NULL;
}
MSNodeDictAssign *
ms_node_dict_assign_new (MSNode *dict,
const char *key,
MSNode *val)
{
MSNodeDictAssign *node;
g_return_val_if_fail (dict != NULL, NULL);
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (val != NULL, NULL);
node = NODE_NEW (MSNodeDictAssign,
MS_TYPE_NODE_DICT_ASSIGN,
ms_node_dict_assign_eval,
ms_node_dict_assign_destroy);
node->dict = ms_node_ref (dict);
node->key = g_strdup (key);
node->val = ms_node_ref (val);
return node;
}
/****************************************************************************/
/* MSNodeDictEntry
*/
static void
ms_node_dict_entry_destroy (MSNode *node_)
{
ms_node_unref (MS_NODE_DICT_ENTRY(node_)->val);
g_free (MS_NODE_DICT_ENTRY(node_)->key);
}
MSNodeDictEntry *
ms_node_dict_entry_new (const char *key,
MSNode *val)
{
MSNodeDictEntry *node;
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (val != NULL, NULL);
node = NODE_NEW (MSNodeDictEntry,
MS_TYPE_NODE_DICT_ENTRY,
NULL,
ms_node_dict_entry_destroy);
node->key = g_strdup (key);
node->val = ms_node_ref (val);
return node;
}
/****************************************************************************/
/* MSNodeDict
*/
static void
ms_node_dict_destroy (MSNode *node_)
{
ms_node_unref (MS_NODE_DICT(node_)->entries);
}
static MSValue *
ms_node_dict_eval (MSNode *node_,
MSContext *ctx)
{
MSValue *ret;
MSNodeDict *node = MS_NODE_DICT (node_);
ret = ms_value_dict ();
if (node->entries)
{
guint i;
for (i = 0; i < node->entries->n_nodes; ++i)
{
MSNodeDictEntry *entry = MS_NODE_DICT_ENTRY (node->entries->nodes[i]);
MSValue *val = _ms_node_eval (entry->val, ctx);
if (!val)
{
ms_value_unref (val);
return NULL;
}
ms_value_dict_set_elm (ret, entry->key, val);
ms_value_unref (val);
}
}
return ret;
}
MSNodeDict *
ms_node_dict_new (MSNodeList *entries)
{
MSNodeDict *node;
g_return_val_if_fail (!entries || MS_IS_NODE_LIST (entries), NULL);
node = NODE_NEW (MSNodeDict,
MS_TYPE_NODE_DICT,
ms_node_dict_eval,
ms_node_dict_destroy);
node->entries = ms_node_ref (entries);
return node;
}

View File

@ -36,6 +36,10 @@ typedef enum {
MS_TYPE_NODE_PYTHON,
MS_TYPE_NODE_RETURN,
MS_TYPE_NODE_BREAK,
MS_TYPE_NODE_DICT_ELM,
MS_TYPE_NODE_DICT_ASSIGN,
MS_TYPE_NODE_DICT,
MS_TYPE_NODE_DICT_ENTRY,
MS_TYPE_NODE_LAST
} MSNodeType;
@ -55,6 +59,10 @@ typedef struct _MSNodeValList MSNodeValList;
typedef struct _MSNodePython MSNodePython;
typedef struct _MSNodeBreak MSNodeBreak;
typedef struct _MSNodeReturn MSNodeReturn;
typedef struct _MSNodeDict MSNodeDict;
typedef struct _MSNodeDictEntry MSNodeDictEntry;
typedef struct _MSNodeDictElm MSNodeDictElm;
typedef struct _MSNodeDictAssign MSNodeDictAssign;
typedef MSValue* (*MSNodeEval) (MSNode *node, MSContext *ctx);
@ -65,7 +73,7 @@ struct _MSNode {
guint ref_count;
MSNodeEval eval;
MSNodeDestroy destroy;
MSNodeType type : 4;
MSNodeType type : 5;
};
#if 0
@ -114,6 +122,10 @@ _ms_node_check_type (gpointer pnode,
#define MS_NODE_PYTHON(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_PYTHON, MSNodePython)
#define MS_NODE_BREAK(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_BREAK, MSNodeBreak)
#define MS_NODE_RETURN(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_RETURN, MSNodeReturn)
#define MS_NODE_DICT(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_DICT, MSNodeDict)
#define MS_NODE_DICT_ENTRY(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_DICT_ENTRY, MSNodeDictEntry)
#define MS_NODE_DICT_ELM(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_DICT_ELM, MSNodeDictElm)
#define MS_NODE_DICT_ASSIGN(node_) MS_NODE_CAST (node_, MS_TYPE_NODE_DICT_ASSIGN, MSNodeDictAssign)
#define MS_IS_NODE_VAR(node) (node && MS_NODE_TYPE(node) == MS_TYPE_NODE_VAR)
#define MS_IS_NODE_VALUE(node) (node && MS_NODE_TYPE(node) == MS_TYPE_NODE_VALUE)
@ -238,6 +250,31 @@ struct _MSNodeReturn {
};
struct _MSNodeDict {
MSNode node;
MSNodeList *entries;
};
struct _MSNodeDictEntry {
MSNode node;
char *key;
MSNode *val;
};
struct _MSNodeDictElm {
MSNode node;
MSNode *dict;
char *key;
};
struct _MSNodeDictAssign {
MSNode node;
MSNode *dict;
char *key;
MSNode *val;
};
gpointer ms_node_ref (gpointer node);
void ms_node_unref (gpointer node);
@ -290,6 +327,15 @@ MSNodeListAssign *ms_node_list_assign_new (MSNode *list,
MSNodeBreak *ms_node_break_new (MSBreakType type);
MSNodeReturn *ms_node_return_new (MSNode *val);
MSNodeDict *ms_node_dict_new (MSNodeList *entries);
MSNodeDictEntry *ms_node_dict_entry_new (const char *key,
MSNode *val);
MSNodeDictElm *ms_node_dict_elm_new (MSNode *dict,
const char *key);
MSNodeDictAssign *ms_node_dict_assign_new (MSNode *dict,
const char *key,
MSNode *val);
G_END_DECLS

View File

@ -178,6 +178,56 @@ ms_value_list_set_elm (MSValue *list,
}
MSValue *
ms_value_dict (void)
{
MSValue *val;
val = ms_value_new (MS_VALUE_DICT);
val->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) ms_value_unref);
return val;
}
MSValue *
ms_value_dict_get_elm (MSValue *dict,
const char *key)
{
MSValue *val;
g_return_val_if_fail (dict != NULL, NULL);
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (dict->type == MS_VALUE_DICT, NULL);
val = g_hash_table_lookup (dict->hash, key);
return val ? ms_value_ref (val) : NULL;
}
void
ms_value_dict_set_elm (MSValue *dict,
const char *key,
MSValue *val)
{
MSValue *old;
g_return_if_fail (dict != NULL);
g_return_if_fail (key != NULL);
g_return_if_fail (dict->type == MS_VALUE_DICT);
old = g_hash_table_lookup (dict->hash, key);
if (old == val)
return;
if (!val)
g_hash_table_remove (dict->hash, key);
else
g_hash_table_insert (dict->hash, g_strdup (key),
ms_value_ref (val));
}
MSValue *
ms_value_ref (MSValue *val)
{
@ -229,6 +279,10 @@ ms_value_unref (MSValue *val)
ms_value_unref (val->list.elms[i]);
g_free (val->list.elms);
break;
case MS_VALUE_DICT:
g_hash_table_destroy (val->hash);
break;
}
g_free (val);
@ -277,6 +331,8 @@ ms_value_get_bool (MSValue *val)
return val->ptr != NULL;
case MS_VALUE_LIST:
return val->list.n_elms != 0;
case MS_VALUE_DICT:
return g_hash_table_size (val->hash) != 0;
case MS_VALUE_GVALUE:
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (val->gval)))
{
@ -419,6 +475,110 @@ print_list (MSValue **elms,
}
typedef struct {
const char *key;
MSValue *val;
} KeyValPair;
static KeyValPair *
key_val_pair_new (const char *key,
MSValue *val)
{
KeyValPair *p;
g_assert (key != NULL);
g_assert (val != NULL);
p = g_new (KeyValPair, 1);
p->key = key;
p->val = val;
return p;
}
static void
key_val_pair_free (KeyValPair *pair)
{
g_free (pair);
}
static void
add_key_val (const char *key,
MSValue *val,
GSList **list)
{
*list = g_slist_prepend (*list, key_val_pair_new (key, val));
}
static int
compare_key_val (KeyValPair *a,
KeyValPair *b)
{
int ret;
ret = strcmp (a->key, b->key);
if (ret)
return ret;
return ms_value_cmp (a->val, b->val);
}
static GSList *
dict_get_pairs (GHashTable *table)
{
GSList *list = NULL;
g_hash_table_foreach (table, (GHFunc) add_key_val, &list);
list = g_slist_sort (list, (GCompareFunc) compare_key_val);
return list;
}
static void
print_dict_elm (KeyValPair *pair,
gpointer user_data)
{
char *strval;
struct {
GString *string;
gboolean first;
} *data = user_data;
if (!data->first)
g_string_append (data->string, ", ");
data->first = FALSE;
strval = ms_value_print (pair->val);
g_string_append_printf (data->string, "%s = %s", pair->key, strval);
g_free (strval);
}
static char *
print_dict (GHashTable *table)
{
GSList *list;
GString *string;
struct {
GString *string;
gboolean first;
} data;
string = g_string_sized_new (6 * g_hash_table_size (table) + 2);
g_string_append_c (string, '{');
list = dict_get_pairs (table);
data.string = string;
data.first = TRUE;
g_slist_foreach (list, (GFunc) print_dict_elm, &data);
g_slist_foreach (list, (GFunc) key_val_pair_free, NULL);
g_slist_free (list);
g_string_append_c (string, '}');
return g_string_free (string, FALSE);
}
char *
ms_value_print (MSValue *val)
{
@ -436,6 +596,8 @@ ms_value_print (MSValue *val)
return g_strdup_printf ("Object %p", val->ptr);
case MS_VALUE_LIST:
return print_list (val->list.elms, val->list.n_elms);
case MS_VALUE_DICT:
return print_dict (val->hash);
case MS_VALUE_GVALUE:
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (val->gval)))
{
@ -596,6 +758,41 @@ list_equal (MSValue *a, MSValue *b)
}
static gboolean
check_key (const char *key,
G_GNUC_UNUSED MSValue *val,
GHashTable *table)
{
return g_hash_table_lookup (table, key) == NULL;
}
static gboolean
check_key_and_val (const char *key,
MSValue *val,
GHashTable *table)
{
MSValue *other = g_hash_table_lookup (table, key);
if (!other)
return TRUE;
else
return !ms_value_equal (val, other);
}
static gboolean
dict_equal (GHashTable *a,
GHashTable *b)
{
if (g_hash_table_find (a, (GHRFunc) check_key_and_val, b))
return FALSE;
if (g_hash_table_find (b, (GHRFunc) check_key, a))
return FALSE;
return TRUE;
}
gboolean
ms_value_equal (MSValue *a, MSValue *b)
{
@ -617,6 +814,8 @@ ms_value_equal (MSValue *a, MSValue *b)
return a->ptr == b->ptr;
case MS_VALUE_LIST:
return list_equal (a, b);
case MS_VALUE_DICT:
return dict_equal (a->hash, b->hash);
case MS_VALUE_GVALUE:
g_return_val_if_reached (FALSE);
}
@ -644,6 +843,42 @@ list_cmp (MSValue *a, MSValue *b)
}
static int
dict_cmp (GHashTable *a,
GHashTable *b)
{
int ret;
GSList *list_a, *list_b, *la, *lb;
list_a = dict_get_pairs (a);
list_b = dict_get_pairs (b);
for (la = list_a, lb = list_b; la && lb; la = la->next, lb = lb->next)
{
KeyValPair *pa = la->data, *pb = lb->data;
ret = compare_key_val (pa, pb);
if (ret)
goto out;
}
if (la)
ret = 1;
else if (lb)
ret = -1;
else
ret = 0;
out:
g_slist_foreach (list_a, (GFunc) key_val_pair_free, NULL);
g_slist_foreach (list_b, (GFunc) key_val_pair_free, NULL);
g_slist_free (list_a);
g_slist_free (list_b);
return ret;
}
int
ms_value_cmp (MSValue *a, MSValue *b)
{
@ -665,6 +900,8 @@ ms_value_cmp (MSValue *a, MSValue *b)
return CMP (a->ptr, b->ptr);
case MS_VALUE_LIST:
return list_cmp (a, b);
case MS_VALUE_DICT:
return dict_cmp (a->hash, b->hash);
case MS_VALUE_GVALUE:
g_return_val_if_reached (CMP (a, b));
}

View File

@ -28,7 +28,8 @@ typedef enum {
MS_VALUE_STRING,
MS_VALUE_OBJECT,
MS_VALUE_GVALUE,
MS_VALUE_LIST
MS_VALUE_LIST,
MS_VALUE_DICT
} MSValueType;
typedef enum {
@ -67,6 +68,7 @@ struct _MSValue {
MSValue **elms;
guint n_elms;
} list;
GHashTable *hash;
};
};
@ -96,6 +98,13 @@ void ms_value_list_set_elm (MSValue *list,
guint index,
MSValue *elm);
MSValue *ms_value_dict (void);
void ms_value_dict_set_elm (MSValue *dict,
const char *key,
MSValue *val);
MSValue *ms_value_dict_get_elm (MSValue *dict,
const char *key);
MSValue *ms_value_ref (MSValue *val);
void ms_value_unref (MSValue *val);

View File

@ -132,8 +132,8 @@
static MSNode *
node_list_add (MSParser *parser,
MSNodeList *list,
MSNode *node)
MSNodeList *list,
MSNode *node)
{
if (!node)
return NULL;
@ -383,6 +383,33 @@ node_list_assign (MSParser *parser,
}
static MSNode *
node_dict (MSParser *parser,
MSNodeList *list)
{
MSNodeDict *node;
node = ms_node_dict_new (list);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_dict_entry (MSParser *parser,
const char *key,
MSNode *val)
{
MSNodeDictEntry *node;
node = ms_node_dict_entry_new (key, val);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_return (MSParser *parser,
MSNode *val)
@ -420,6 +447,36 @@ node_continue (MSParser *parser)
}
static MSNode *
node_dict_elm (MSParser *parser,
MSNode *dict,
const char *key)
{
MSNodeDictElm *node;
node = ms_node_dict_elm_new (dict, key);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_dict_assign (MSParser *parser,
MSNode *dict,
const char *key,
MSNode *val)
{
MSNodeDictAssign *node;
node = ms_node_dict_assign_new (dict, key, val);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@ -439,14 +496,14 @@ node_continue (MSParser *parser)
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 298 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 355 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
typedef union YYSTYPE {
int ival;
const char *str;
MSNode *node;
} YYSTYPE;
/* Line 196 of yacc.c. */
#line 450 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
#line 507 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@ -458,7 +515,7 @@ typedef union YYSTYPE {
/* Line 219 of yacc.c. */
#line 462 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
#line 519 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
@ -607,18 +664,18 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 45
#define YYFINAL 49
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 574
#define YYLAST 634
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 46
#define YYNTOKENS 49
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 14
#define YYNNTS 16
/* YYNRULES -- Number of rules. */
#define YYNRULES 54
#define YYNRULES 61
/* YYNRULES -- Number of states. */
#define YYNSTATES 113
#define YYNSTATES 128
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
@ -634,15 +691,15 @@ static const unsigned char yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 36, 2, 33, 2, 2,
43, 44, 31, 30, 45, 29, 2, 32, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 42, 37,
34, 38, 35, 41, 2, 2, 2, 2, 2, 2,
44, 45, 31, 30, 48, 29, 41, 32, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 43, 37,
34, 38, 35, 42, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 39, 2, 40, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 46, 2, 47, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@ -668,45 +725,50 @@ static const unsigned char yyprhs[] =
{
0, 0, 3, 5, 7, 10, 13, 15, 16, 18,
20, 22, 24, 26, 28, 30, 33, 39, 44, 52,
58, 66, 68, 70, 72, 76, 83, 89, 93, 97,
101, 105, 109, 113, 117, 121, 125, 129, 133, 137,
140, 143, 146, 150, 152, 154, 156, 160, 164, 170,
175, 180, 181, 183, 187
58, 66, 68, 70, 72, 76, 83, 89, 95, 99,
103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
143, 146, 149, 152, 156, 158, 160, 162, 166, 170,
174, 180, 185, 190, 194, 195, 197, 201, 202, 204,
208, 212
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yysigned_char yyrhs[] =
{
47, 0, -1, 48, -1, 49, -1, 48, 49, -1,
50, 37, -1, 6, -1, -1, 53, -1, 52, -1,
51, -1, 54, -1, 17, -1, 18, -1, 19, -1,
19, 53, -1, 12, 53, 13, 48, 14, -1, 13,
48, 12, 53, -1, 15, 59, 16, 53, 13, 48,
14, -1, 8, 53, 9, 48, 11, -1, 8, 53,
9, 48, 10, 48, 11, -1, 57, -1, 56, -1,
55, -1, 3, 38, 53, -1, 57, 39, 53, 40,
38, 53, -1, 57, 41, 57, 42, 57, -1, 53,
30, 53, -1, 53, 29, 53, -1, 53, 32, 53,
-1, 53, 31, 53, -1, 53, 24, 53, -1, 53,
25, 53, -1, 53, 20, 53, -1, 53, 21, 53,
-1, 53, 34, 53, -1, 53, 35, 53, -1, 53,
22, 53, -1, 53, 23, 53, -1, 29, 57, -1,
26, 57, -1, 36, 57, -1, 57, 33, 57, -1,
7, -1, 4, -1, 59, -1, 43, 50, 44, -1,
39, 58, 40, -1, 39, 53, 28, 53, 40, -1,
3, 43, 58, 44, -1, 57, 39, 53, 40, -1,
-1, 53, -1, 58, 45, 53, -1, 3, -1
50, 0, -1, 51, -1, 52, -1, 51, 52, -1,
53, 37, -1, 6, -1, -1, 56, -1, 55, -1,
54, -1, 57, -1, 17, -1, 18, -1, 19, -1,
19, 56, -1, 12, 56, 13, 51, 14, -1, 13,
51, 12, 56, -1, 15, 64, 16, 56, 13, 51,
14, -1, 8, 56, 9, 51, 11, -1, 8, 56,
9, 51, 10, 51, 11, -1, 60, -1, 59, -1,
58, -1, 3, 38, 56, -1, 60, 39, 56, 40,
38, 56, -1, 60, 41, 3, 38, 56, -1, 60,
42, 60, 43, 60, -1, 56, 30, 56, -1, 56,
29, 56, -1, 56, 32, 56, -1, 56, 31, 56,
-1, 56, 24, 56, -1, 56, 25, 56, -1, 56,
20, 56, -1, 56, 21, 56, -1, 56, 34, 56,
-1, 56, 35, 56, -1, 56, 22, 56, -1, 56,
23, 56, -1, 29, 60, -1, 26, 60, -1, 36,
60, -1, 60, 33, 60, -1, 7, -1, 4, -1,
64, -1, 44, 53, 45, -1, 39, 61, 40, -1,
46, 62, 47, -1, 39, 56, 28, 56, 40, -1,
3, 44, 61, 45, -1, 60, 39, 56, 40, -1,
60, 41, 3, -1, -1, 56, -1, 61, 48, 56,
-1, -1, 63, -1, 62, 48, 63, -1, 3, 38,
56, -1, 3, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short int yyrline[] =
{
0, 338, 338, 341, 342, 346, 347, 350, 351, 352,
353, 354, 355, 356, 357, 358, 361, 362, 363, 367,
368, 371, 372, 373, 377, 378, 381, 385, 386, 387,
388, 390, 391, 393, 394, 395, 396, 397, 398, 399,
400, 401, 402, 406, 407, 408, 409, 410, 411, 412,
413, 416, 417, 418, 421
0, 396, 396, 399, 400, 404, 405, 408, 409, 410,
411, 412, 413, 414, 415, 416, 419, 420, 421, 425,
426, 429, 430, 431, 435, 436, 437, 440, 444, 445,
446, 447, 449, 450, 452, 453, 454, 455, 456, 457,
458, 459, 460, 461, 465, 466, 467, 468, 469, 470,
471, 472, 473, 474, 477, 478, 479, 482, 483, 484,
487, 490
};
#endif
@ -719,10 +781,11 @@ static const char *const yytname[] =
"PYTHON", "NUMBER", "IF", "THEN", "ELSE", "FI", "WHILE", "DO", "OD",
"FOR", "IN", "CONTINUE", "BREAK", "RETURN", "EQ", "NEQ", "LE", "GE",
"AND", "OR", "NOT", "UMINUS", "TWODOTS", "'-'", "'+'", "'*'", "'/'",
"'%'", "'<'", "'>'", "'#'", "';'", "'='", "'['", "']'", "'?'", "':'",
"'('", "')'", "','", "$accept", "script", "program", "stmt_or_python",
"stmt", "loop", "if_stmt", "expr", "assignment", "ternary",
"compound_expr", "simple_expr", "list_elms", "variable", 0
"'%'", "'<'", "'>'", "'#'", "';'", "'='", "'['", "']'", "'.'", "'?'",
"':'", "'('", "')'", "'{'", "'}'", "','", "$accept", "script", "program",
"stmt_or_python", "stmt", "loop", "if_stmt", "expr", "assignment",
"ternary", "compound_expr", "simple_expr", "list_elms", "dict_elms",
"dict_entry", "variable", 0
};
#endif
@ -735,19 +798,20 @@ static const unsigned short int yytoknum[] =
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 45,
43, 42, 47, 37, 60, 62, 35, 59, 61, 91,
93, 63, 58, 40, 41, 44
93, 46, 63, 58, 40, 41, 123, 125, 44
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const unsigned char yyr1[] =
{
0, 46, 47, 48, 48, 49, 49, 50, 50, 50,
50, 50, 50, 50, 50, 50, 51, 51, 51, 52,
52, 53, 53, 53, 54, 54, 55, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 57, 57, 57, 57, 57, 57, 57,
57, 58, 58, 58, 59
0, 49, 50, 51, 51, 52, 52, 53, 53, 53,
53, 53, 53, 53, 53, 53, 54, 54, 54, 55,
55, 56, 56, 56, 57, 57, 57, 58, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 60, 60, 60, 60, 60, 60,
60, 60, 60, 60, 61, 61, 61, 62, 62, 62,
63, 64
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@ -755,10 +819,11 @@ static const unsigned char yyr2[] =
{
0, 2, 1, 1, 2, 2, 1, 0, 1, 1,
1, 1, 1, 1, 1, 2, 5, 4, 7, 5,
7, 1, 1, 1, 3, 6, 5, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 2,
2, 2, 3, 1, 1, 1, 3, 3, 5, 4,
4, 0, 1, 3, 1
7, 1, 1, 1, 3, 6, 5, 5, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 3, 1, 1, 1, 3, 3, 3,
5, 4, 4, 3, 0, 1, 3, 0, 1, 3,
3, 1
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@ -766,51 +831,53 @@ static const unsigned char yyr2[] =
means the default is an error. */
static const unsigned char yydefact[] =
{
7, 54, 44, 6, 43, 0, 0, 7, 0, 12,
13, 14, 0, 0, 0, 51, 7, 0, 2, 3,
0, 10, 9, 8, 11, 23, 22, 21, 45, 0,
51, 54, 0, 21, 0, 7, 54, 0, 15, 40,
39, 41, 52, 0, 0, 1, 4, 5, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 24, 52, 0, 7, 0, 7, 0,
0, 0, 47, 0, 46, 33, 34, 37, 38, 31,
32, 28, 27, 30, 29, 35, 36, 42, 0, 0,
49, 7, 0, 7, 17, 0, 0, 53, 50, 0,
7, 19, 50, 16, 7, 48, 0, 26, 7, 7,
25, 20, 18
7, 61, 45, 6, 44, 0, 0, 7, 0, 12,
13, 14, 0, 0, 0, 54, 7, 57, 0, 2,
3, 0, 10, 9, 8, 11, 23, 22, 21, 46,
0, 54, 61, 0, 21, 0, 7, 61, 0, 15,
41, 40, 42, 55, 0, 0, 0, 0, 58, 1,
4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 24, 55,
0, 7, 0, 0, 7, 0, 0, 0, 48, 0,
47, 0, 49, 0, 34, 35, 38, 39, 32, 33,
29, 28, 31, 30, 36, 37, 43, 0, 53, 0,
51, 7, 0, 53, 7, 17, 0, 0, 56, 60,
59, 52, 0, 0, 7, 19, 52, 16, 7, 50,
0, 26, 27, 7, 7, 25, 20, 18
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yysigned_char yydefgoto[] =
{
-1, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 33, 43, 28
-1, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 34, 44, 47, 48, 29
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -31
#define YYPACT_NINF -44
static const short int yypact[] =
{
296, -28, -31, -31, -31, -2, -2, 296, 5, -31,
-31, -2, 18, 18, 18, -2, 364, 6, 156, -31,
-20, -31, -31, 523, -31, -31, -31, -30, -31, -2,
-2, -24, 388, -13, 408, 330, -31, 7, 523, -10,
-10, -10, 507, -7, -5, -31, -31, -31, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
18, -2, 18, 523, 523, -1, 296, -2, 296, -2,
-2, -2, -31, -2, -31, 22, 22, 22, 22, -31,
24, 539, 539, 132, 132, 22, 22, -10, 444, 3,
-31, 122, 465, 194, 408, 428, 486, 523, 12, 18,
296, -31, -31, -31, 296, -31, -2, -10, 228, 262,
523, -31, -31
330, -35, -44, -44, -44, 236, 236, 330, 12, -44,
-44, 236, 31, 31, 31, 236, 404, 34, 51, 154,
-44, 17, -44, -44, 567, -44, -44, -44, -31, -44,
236, 236, 15, 432, 6, 452, 374, -44, 45, 567,
-11, -11, -11, 551, 1, 18, 24, -43, -44, -44,
-44, -44, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 31, 236, 63, 31, 567, 567,
7, 330, 236, 66, 330, 236, 236, 236, -44, 236,
-44, 236, -44, 34, 32, 32, 32, 32, -44, 48,
583, 583, 599, 599, 32, 32, -11, 488, 35, 3,
-44, 14, 509, -44, 198, 452, 472, 530, 567, 567,
-44, 38, 236, 31, 330, -44, -44, -44, 330, -44,
236, 567, -11, 242, 286, 567, -44, -44
};
/* YYPGOTO[NTERM-NUM]. */
static const yysigned_char yypgoto[] =
{
-31, -31, -3, 14, 35, -31, -31, 25, -31, -31,
-31, 0, 23, 44
-44, -44, -6, -13, 62, -44, -44, 75, -44, -44,
-44, 0, 52, -44, -4, 74
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -820,126 +887,138 @@ static const yysigned_char yypgoto[] =
#define YYTABLE_NINF -8
static const yysigned_char yytable[] =
{
27, 31, 2, 60, 35, 4, 45, 27, 36, 61,
29, 62, 39, 40, 41, 30, 27, 47, 27, 30,
60, 31, 2, 70, 12, 4, 67, 13, 62, 67,
32, 34, 46, 72, 14, 27, 38, 15, 73, 74,
42, 16, 67, 90, 73, 99, 52, 53, 52, 46,
106, 44, 37, 65, 63, 64, 0, 15, 0, 0,
87, 16, 89, 91, 0, 93, 27, 0, 27, 0,
0, 0, 0, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 0, 88, 0, 0, 0,
0, 27, 92, 27, 94, 95, 96, 108, 97, 107,
27, 109, 0, 0, 27, 46, 0, 46, 27, 27,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 46, 46, 0, 1, 2, 0, 3, 4,
5, 110, 100, 101, 6, 7, 0, 8, 0, 9,
10, 11, 0, 0, 0, 0, 0, 0, 12, 0,
0, 13, 48, 49, 50, 51, 52, 53, 14, 1,
2, 15, 3, 4, 5, 16, 58, 59, 6, 7,
0, 8, 0, 9, 10, 11, 0, 0, 0, 0,
0, 0, 12, 0, 0, 13, 0, 0, 0, 0,
0, 0, 14, -7, 0, 15, 0, 1, 2, 16,
3, 4, 5, 0, 0, 0, 6, 7, 103, 8,
28, 36, 64, 30, 82, 83, 50, 28, 65, 31,
66, 67, 40, 41, 42, 37, 28, 1, 2, 28,
3, 4, 5, 50, 114, 115, 6, 7, 72, 8,
73, 9, 10, 11, 32, 2, 28, 46, 4, 64,
12, 78, 72, 13, 73, 72, 113, 73, 67, 79,
14, 49, 100, 15, 51, 79, 56, 57, 16, 31,
17, 76, 81, 80, 96, 101, 98, 99, 104, 103,
15, 28, 56, 112, 28, 16, 120, 17, 45, 110,
33, 35, 38, 70, 0, 0, 39, 0, 50, 0,
43, 50, 0, 0, 0, 0, 0, 0, 0, 0,
0, 28, 0, 0, 28, 68, 69, 0, 123, 0,
50, 50, 124, 122, 28, 0, 0, 0, 28, 0,
0, 0, 0, 28, 28, 0, 0, 84, 85, 86,
87, 88, 89, 90, 91, 92, 93, 94, 95, 0,
97, 0, 0, 0, 0, 0, 0, 102, 0, 0,
105, 106, 107, 0, 108, 0, 109, 1, 2, 0,
3, 4, 5, 0, 0, 0, 6, 7, 0, 8,
0, 9, 10, 11, 0, 0, 0, 0, 0, 0,
12, 0, 0, 13, 0, 0, 0, 0, 0, 0,
14, 1, 2, 15, 3, 4, 5, 16, 0, 111,
6, 7, 0, 8, 0, 9, 10, 11, 0, 0,
12, 0, 0, 13, 0, 0, 0, 121, 0, 0,
14, -7, 0, 15, 0, 125, 0, 0, 16, 0,
17, 1, 2, 0, 3, 4, 5, 0, 0, 0,
6, 7, 117, 8, 0, 9, 10, 11, 0, 0,
0, 0, 0, 0, 12, 0, 0, 13, 0, 0,
0, 0, 0, 0, 14, 1, 2, 15, 3, 4,
5, 16, 0, 0, 6, 7, 112, 8, 0, 9,
10, 11, 0, 0, 0, 0, 0, 0, 12, 0,
0, 13, 0, 0, 0, 0, 0, 0, 14, 1,
2, 15, 3, 4, 5, 16, 0, 0, 6, 7,
0, 8, 0, 9, 10, 11, 0, 0, 0, 0,
0, 0, 0, 0, 14, 0, 0, 15, 0, 32,
2, 0, 16, 4, 17, 1, 2, 0, 3, 4,
5, 0, 0, 126, 6, 7, 0, 8, 0, 9,
10, 11, 12, 0, 0, 13, 0, 0, 12, 0,
0, 13, 14, 0, 0, 15, 0, 0, 14, 0,
16, 15, 17, 0, 0, 0, 16, 0, 17, 1,
2, 0, 3, 4, 5, 0, 0, 0, 6, 7,
127, 8, 0, 9, 10, 11, 0, 0, 0, 0,
0, 0, 12, 0, 0, 13, 0, 0, 0, 0,
0, 0, 14, 1, 2, 15, 3, 4, 5, 16,
0, 0, 69, 7, 0, 8, 0, 9, 10, 11,
0, 0, 14, 0, 0, 15, 0, 0, 0, 0,
16, 0, 17, 1, 2, 0, 3, 4, 5, 0,
0, 0, 6, 7, 0, 8, 0, 9, 10, 11,
0, 0, 0, 0, 0, 0, 12, 0, 0, 13,
0, 0, 0, 0, 0, 0, 14, 1, 2, 15,
0, 4, 5, 16, 0, 0, 6, 7, 0, 8,
0, 0, 0, 0, 0, 0, 14, 0, 0, 15,
0, 0, 0, 0, 16, 0, 17, 1, 2, 0,
3, 4, 5, 0, 0, 0, 75, 7, 0, 8,
0, 9, 10, 11, 0, 0, 0, 0, 0, 0,
12, 0, 0, 13, 0, 0, 0, 66, 0, 0,
14, 0, 0, 15, 0, 0, 0, 16, 48, 49,
50, 51, 52, 53, 0, 0, 0, 54, 55, 56,
57, 68, 58, 59, 0, 0, 0, 0, 48, 49,
50, 51, 52, 53, 0, 0, 0, 54, 55, 56,
57, 104, 58, 59, 0, 0, 0, 0, 48, 49,
50, 51, 52, 53, 0, 0, 0, 54, 55, 56,
57, 0, 58, 59, 48, 49, 50, 51, 52, 53,
0, 0, 0, 54, 55, 56, 57, 0, 58, 59,
0, 0, 0, 0, 98, 48, 49, 50, 51, 52,
53, 0, 0, 0, 54, 55, 56, 57, 0, 58,
59, 0, 0, 0, 0, 102, 48, 49, 50, 51,
52, 53, 0, 0, 0, 54, 55, 56, 57, 0,
58, 59, 0, 0, 0, 0, 105, 48, 49, 50,
51, 52, 53, 0, 0, 71, 54, 55, 56, 57,
0, 58, 59, 48, 49, 50, 51, 52, 53, 0,
0, 0, 54, 55, 56, 57, 0, 58, 59, 48,
49, 50, 51, 52, 53, 0, 0, 0, 0, 0,
56, 57, 0, 58, 59
12, 0, 0, 13, 0, 0, 0, 1, 2, 0,
14, 4, 5, 15, 0, 0, 6, 7, 16, 8,
17, 9, 10, 11, 0, 0, 0, 0, 0, 0,
12, 0, 0, 13, 0, 0, 0, 0, 0, 0,
14, 71, 0, 15, 0, 0, 0, 0, 16, 0,
17, 0, 52, 53, 54, 55, 56, 57, 0, 0,
0, 58, 59, 60, 61, 74, 62, 63, 0, 0,
0, 0, 52, 53, 54, 55, 56, 57, 0, 0,
0, 58, 59, 60, 61, 118, 62, 63, 0, 0,
0, 0, 52, 53, 54, 55, 56, 57, 0, 0,
0, 58, 59, 60, 61, 0, 62, 63, 52, 53,
54, 55, 56, 57, 0, 0, 0, 58, 59, 60,
61, 0, 62, 63, 0, 0, 0, 0, 111, 52,
53, 54, 55, 56, 57, 0, 0, 0, 58, 59,
60, 61, 0, 62, 63, 0, 0, 0, 0, 116,
52, 53, 54, 55, 56, 57, 0, 0, 0, 58,
59, 60, 61, 0, 62, 63, 0, 0, 0, 0,
119, 52, 53, 54, 55, 56, 57, 0, 0, 77,
58, 59, 60, 61, 0, 62, 63, 52, 53, 54,
55, 56, 57, 0, 0, 0, 58, 59, 60, 61,
0, 62, 63, 52, 53, 54, 55, 56, 57, 0,
0, 0, 0, 0, 60, 61, 0, 62, 63, 52,
53, 54, 55, 56, 57, 0, 0, 0, 0, 0,
0, 0, 0, 62, 63
};
static const yysigned_char yycheck[] =
{
0, 3, 4, 33, 7, 7, 0, 7, 3, 39,
38, 41, 12, 13, 14, 43, 16, 37, 18, 43,
33, 3, 4, 16, 26, 7, 39, 29, 41, 39,
5, 6, 18, 40, 36, 35, 11, 39, 45, 44,
15, 43, 39, 44, 45, 42, 24, 25, 24, 35,
38, 16, 8, 30, 29, 30, -1, 39, -1, -1,
60, 43, 62, 66, -1, 68, 66, -1, 68, -1,
-1, -1, -1, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, -1, 61, -1, -1, -1,
-1, 91, 67, 93, 69, 70, 71, 100, 73, 99,
100, 104, -1, -1, 104, 91, -1, 93, 108, 109,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 108, 109, -1, 3, 4, -1, 6, 7,
8, 106, 10, 11, 12, 13, -1, 15, -1, 17,
18, 19, -1, -1, -1, -1, -1, -1, 26, -1,
-1, 29, 20, 21, 22, 23, 24, 25, 36, 3,
4, 39, 6, 7, 8, 43, 34, 35, 12, 13,
-1, 15, -1, 17, 18, 19, -1, -1, -1, -1,
-1, -1, 26, -1, -1, 29, -1, -1, -1, -1,
-1, -1, 36, 37, -1, 39, -1, 3, 4, 43,
6, 7, 8, -1, -1, -1, 12, 13, 14, 15,
0, 7, 33, 38, 47, 48, 19, 7, 39, 44,
41, 42, 12, 13, 14, 3, 16, 3, 4, 19,
6, 7, 8, 36, 10, 11, 12, 13, 39, 15,
41, 17, 18, 19, 3, 4, 36, 3, 7, 33,
26, 40, 39, 29, 41, 39, 43, 41, 42, 48,
36, 0, 45, 39, 37, 48, 24, 25, 44, 44,
46, 16, 38, 45, 64, 71, 3, 67, 74, 3,
39, 71, 24, 38, 74, 44, 38, 46, 16, 83,
5, 6, 8, 31, -1, -1, 11, -1, 101, -1,
15, 104, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 101, -1, -1, 104, 30, 31, -1, 114, -1,
123, 124, 118, 113, 114, -1, -1, -1, 118, -1,
-1, -1, -1, 123, 124, -1, -1, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, -1,
65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
75, 76, 77, -1, 79, -1, 81, 3, 4, -1,
6, 7, 8, -1, -1, -1, 12, 13, -1, 15,
-1, 17, 18, 19, -1, -1, -1, -1, -1, -1,
26, -1, -1, 29, -1, -1, -1, -1, -1, -1,
36, 3, 4, 39, 6, 7, 8, 43, -1, 11,
12, 13, -1, 15, -1, 17, 18, 19, -1, -1,
26, -1, -1, 29, -1, -1, -1, 112, -1, -1,
36, 37, -1, 39, -1, 120, -1, -1, 44, -1,
46, 3, 4, -1, 6, 7, 8, -1, -1, -1,
12, 13, 14, 15, -1, 17, 18, 19, -1, -1,
-1, -1, -1, -1, 26, -1, -1, 29, -1, -1,
-1, -1, -1, -1, 36, 3, 4, 39, 6, 7,
8, 43, -1, -1, 12, 13, 14, 15, -1, 17,
18, 19, -1, -1, -1, -1, -1, -1, 26, -1,
-1, 29, -1, -1, -1, -1, -1, -1, 36, 3,
4, 39, 6, 7, 8, 43, -1, -1, 12, 13,
-1, 15, -1, 17, 18, 19, -1, -1, -1, -1,
-1, -1, -1, -1, 36, -1, -1, 39, -1, 3,
4, -1, 44, 7, 46, 3, 4, -1, 6, 7,
8, -1, -1, 11, 12, 13, -1, 15, -1, 17,
18, 19, 26, -1, -1, 29, -1, -1, 26, -1,
-1, 29, 36, -1, -1, 39, -1, -1, 36, -1,
44, 39, 46, -1, -1, -1, 44, -1, 46, 3,
4, -1, 6, 7, 8, -1, -1, -1, 12, 13,
14, 15, -1, 17, 18, 19, -1, -1, -1, -1,
-1, -1, 26, -1, -1, 29, -1, -1, -1, -1,
-1, -1, 36, 3, 4, 39, 6, 7, 8, 43,
-1, -1, 36, -1, -1, 39, -1, -1, -1, -1,
44, -1, 46, 3, 4, -1, 6, 7, 8, -1,
-1, -1, 12, 13, -1, 15, -1, 17, 18, 19,
-1, -1, -1, -1, -1, -1, 26, -1, -1, 29,
-1, -1, -1, -1, -1, -1, 36, 3, 4, 39,
-1, 7, 8, 43, -1, -1, 12, 13, -1, 15,
-1, -1, -1, -1, -1, -1, 36, -1, -1, 39,
-1, -1, -1, -1, 44, -1, 46, 3, 4, -1,
6, 7, 8, -1, -1, -1, 12, 13, -1, 15,
-1, 17, 18, 19, -1, -1, -1, -1, -1, -1,
26, -1, -1, 29, -1, -1, -1, 9, -1, -1,
36, -1, -1, 39, -1, -1, -1, 43, 20, 21,
26, -1, -1, 29, -1, -1, -1, 3, 4, -1,
36, 7, 8, 39, -1, -1, 12, 13, 44, 15,
46, 17, 18, 19, -1, -1, -1, -1, -1, -1,
26, -1, -1, 29, -1, -1, -1, -1, -1, -1,
36, 9, -1, 39, -1, -1, -1, -1, 44, -1,
46, -1, 20, 21, 22, 23, 24, 25, -1, -1,
-1, 29, 30, 31, 32, 13, 34, 35, -1, -1,
-1, -1, 20, 21, 22, 23, 24, 25, -1, -1,
-1, 29, 30, 31, 32, 13, 34, 35, -1, -1,
-1, -1, 20, 21, 22, 23, 24, 25, -1, -1,
-1, 29, 30, 31, 32, -1, 34, 35, 20, 21,
22, 23, 24, 25, -1, -1, -1, 29, 30, 31,
32, 13, 34, 35, -1, -1, -1, -1, 20, 21,
22, 23, 24, 25, -1, -1, -1, 29, 30, 31,
32, 13, 34, 35, -1, -1, -1, -1, 20, 21,
22, 23, 24, 25, -1, -1, -1, 29, 30, 31,
32, -1, 34, 35, 20, 21, 22, 23, 24, 25,
-1, -1, -1, 29, 30, 31, 32, -1, 34, 35,
-1, -1, -1, -1, 40, 20, 21, 22, 23, 24,
25, -1, -1, -1, 29, 30, 31, 32, -1, 34,
35, -1, -1, -1, -1, 40, 20, 21, 22, 23,
24, 25, -1, -1, -1, 29, 30, 31, 32, -1,
34, 35, -1, -1, -1, -1, 40, 20, 21, 22,
23, 24, 25, -1, -1, 28, 29, 30, 31, 32,
32, -1, 34, 35, -1, -1, -1, -1, 40, 20,
21, 22, 23, 24, 25, -1, -1, -1, 29, 30,
31, 32, -1, 34, 35, -1, -1, -1, -1, 40,
20, 21, 22, 23, 24, 25, -1, -1, -1, 29,
30, 31, 32, -1, 34, 35, -1, -1, -1, -1,
40, 20, 21, 22, 23, 24, 25, -1, -1, 28,
29, 30, 31, 32, -1, 34, 35, 20, 21, 22,
23, 24, 25, -1, -1, -1, 29, 30, 31, 32,
-1, 34, 35, 20, 21, 22, 23, 24, 25, -1,
-1, -1, 29, 30, 31, 32, -1, 34, 35, 20,
-1, -1, -1, -1, 31, 32, -1, 34, 35, 20,
21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
31, 32, -1, 34, 35
-1, -1, -1, 34, 35
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -947,17 +1026,18 @@ static const yysigned_char yycheck[] =
static const unsigned char yystos[] =
{
0, 3, 4, 6, 7, 8, 12, 13, 15, 17,
18, 19, 26, 29, 36, 39, 43, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 59, 38,
43, 3, 53, 57, 53, 48, 3, 59, 53, 57,
57, 57, 53, 58, 50, 0, 49, 37, 20, 21,
22, 23, 24, 25, 29, 30, 31, 32, 34, 35,
33, 39, 41, 53, 53, 58, 9, 39, 13, 12,
16, 28, 40, 45, 44, 53, 53, 53, 53, 53,
53, 53, 53, 53, 53, 53, 53, 57, 53, 57,
44, 48, 53, 48, 53, 53, 53, 53, 40, 42,
10, 11, 40, 14, 13, 40, 38, 57, 48, 48,
53, 11, 14
18, 19, 26, 29, 36, 39, 44, 46, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 64,
38, 44, 3, 56, 60, 56, 51, 3, 64, 56,
60, 60, 60, 56, 61, 53, 3, 62, 63, 0,
52, 37, 20, 21, 22, 23, 24, 25, 29, 30,
31, 32, 34, 35, 33, 39, 41, 42, 56, 56,
61, 9, 39, 41, 13, 12, 16, 28, 40, 48,
45, 38, 47, 48, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 60, 56, 3, 60,
45, 51, 56, 3, 51, 56, 56, 56, 56, 56,
63, 40, 38, 43, 10, 11, 40, 14, 13, 40,
38, 56, 60, 51, 51, 56, 11, 14
};
#define yyerrok (yyerrstatus = 0)
@ -1627,227 +1707,262 @@ yyreduce:
switch (yyn)
{
case 2:
#line 338 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 396 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ _ms_parser_set_top_node (parser, (yyvsp[0].node)); ;}
break;
case 3:
#line 341 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 399 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, NULL, (yyvsp[0].node)); ;}
break;
case 4:
#line 342 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 400 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, MS_NODE_LIST ((yyvsp[-1].node)), (yyvsp[0].node)); ;}
break;
case 5:
#line 346 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 404 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = (yyvsp[-1].node); ;}
break;
case 6:
#line 347 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 405 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_python (parser, (yyvsp[0].str)); ;}
break;
case 7:
#line 350 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 408 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = NULL; ;}
break;
case 12:
#line 355 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 413 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_continue (parser); ;}
break;
case 13:
#line 356 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 414 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_break (parser); ;}
break;
case 14:
#line 357 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 415 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_return (parser, NULL); ;}
break;
case 15:
#line 358 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 416 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_return (parser, (yyvsp[0].node)); ;}
break;
case 16:
#line 361 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 419 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_while (parser, MS_COND_BEFORE, (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 17:
#line 362 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 420 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_while (parser, MS_COND_AFTER, (yyvsp[0].node), (yyvsp[-2].node)); ;}
break;
case 18:
#line 363 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 421 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_for (parser, (yyvsp[-5].node), (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 19:
#line 367 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 425 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_if_else (parser, (yyvsp[-3].node), (yyvsp[-1].node), NULL); ;}
break;
case 20:
#line 368 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 426 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_if_else (parser, (yyvsp[-5].node), (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 24:
#line 377 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 435 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_assignment (parser, (yyvsp[-2].str), (yyvsp[0].node)); ;}
break;
case 25:
#line 378 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 436 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_assign (parser, (yyvsp[-5].node), (yyvsp[-3].node), (yyvsp[0].node)); ;}
break;
case 26:
#line 381 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_if_else (parser, (yyvsp[-4].node), (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 437 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_dict_assign (parser, (yyvsp[-4].node), (yyvsp[-2].str), (yyvsp[0].node)); ;}
break;
case 27:
#line 385 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_PLUS, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 440 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_if_else (parser, (yyvsp[-4].node), (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 28:
#line 386 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_MINUS, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 444 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_PLUS, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 29:
#line 387 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_DIV, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 445 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_MINUS, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 30:
#line 388 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_MULT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 446 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_DIV, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 31:
#line 390 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_AND, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 447 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_MULT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 32:
#line 391 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_OR, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 449 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_AND, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 33:
#line 393 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_EQ, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 450 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_OR, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 34:
#line 394 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_NEQ, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 452 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_EQ, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 35:
#line 395 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_LT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 453 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_NEQ, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 36:
#line 396 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_GT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 454 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_LT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 37:
#line 397 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_LE, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 455 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_GT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 38:
#line 398 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_GE, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 456 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_LE, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 39:
#line 399 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_UMINUS, (yyvsp[0].node)); ;}
#line 457 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_GE, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 40:
#line 400 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_NOT, (yyvsp[0].node)); ;}
#line 458 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_UMINUS, (yyvsp[0].node)); ;}
break;
case 41:
#line 401 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_LEN, (yyvsp[0].node)); ;}
#line 459 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_NOT, (yyvsp[0].node)); ;}
break;
case 42:
#line 402 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_FORMAT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
#line 460 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_unary_op (parser, MS_OP_LEN, (yyvsp[0].node)); ;}
break;
case 43:
#line 406 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_int (parser, (yyvsp[0].ival)); ;}
#line 461 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_binary_op (parser, MS_OP_FORMAT, (yyvsp[-2].node), (yyvsp[0].node)); ;}
break;
case 44:
#line 407 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 465 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_int (parser, (yyvsp[0].ival)); ;}
break;
case 45:
#line 466 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_string (parser, (yyvsp[0].str)); ;}
break;
case 46:
#line 409 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
case 47:
#line 468 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = (yyvsp[-1].node); ;}
break;
case 47:
#line 410 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
case 48:
#line 469 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_value_list (parser, MS_NODE_LIST ((yyvsp[-1].node))); ;}
break;
case 48:
#line 411 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_value_range (parser, (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 49:
#line 412 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_command (parser, (yyvsp[-3].str), (yyvsp[-1].node) ? MS_NODE_LIST ((yyvsp[-1].node)) : NULL); ;}
#line 470 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_dict (parser, (yyvsp[-1].node) ? MS_NODE_LIST ((yyvsp[-1].node)) : NULL); ;}
break;
case 50:
#line 413 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_elm (parser, (yyvsp[-3].node), (yyvsp[-1].node)); ;}
#line 471 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_value_range (parser, (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 51:
#line 416 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = NULL; ;}
#line 472 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_command (parser, (yyvsp[-3].str), (yyvsp[-1].node) ? MS_NODE_LIST ((yyvsp[-1].node)) : NULL); ;}
break;
case 52:
#line 417 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, NULL, (yyvsp[0].node)); ;}
#line 473 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_elm (parser, (yyvsp[-3].node), (yyvsp[-1].node)); ;}
break;
case 53:
#line 418 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, MS_NODE_LIST ((yyvsp[-2].node)), (yyvsp[0].node)); ;}
#line 474 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_dict_elm (parser, (yyvsp[-2].node), (yyvsp[0].str)); ;}
break;
case 54:
#line 421 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 477 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = NULL; ;}
break;
case 55:
#line 478 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, NULL, (yyvsp[0].node)); ;}
break;
case 56:
#line 479 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, MS_NODE_LIST ((yyvsp[-2].node)), (yyvsp[0].node)); ;}
break;
case 57:
#line 482 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = NULL; ;}
break;
case 58:
#line 483 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, NULL, (yyvsp[0].node)); ;}
break;
case 59:
#line 484 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_list_add (parser, MS_NODE_LIST ((yyvsp[-2].node)), (yyvsp[0].node)); ;}
break;
case 60:
#line 487 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_dict_entry (parser, (yyvsp[-2].str), (yyvsp[0].node)); ;}
break;
case 61:
#line 490 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
{ (yyval.node) = node_var (parser, (yyvsp[0].str)); ;}
break;
@ -1856,7 +1971,7 @@ yyreduce:
}
/* Line 1126 of yacc.c. */
#line 1860 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
#line 1975 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.c"
yyvsp -= yylen;
yyssp -= yylen;
@ -2124,6 +2239,6 @@ yyreturn:
}
#line 424 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 493 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"

View File

@ -89,7 +89,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 298 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
#line 355 "/home/muntyan/projects/ggap/ggap/moo/mooutils/mooscript/mooscript-yacc.y"
typedef union YYSTYPE {
int ival;
const char *str;

View File

@ -5,8 +5,8 @@
static MSNode *
node_list_add (MSParser *parser,
MSNodeList *list,
MSNode *node)
MSNodeList *list,
MSNode *node)
{
if (!node)
return NULL;
@ -256,6 +256,33 @@ node_list_assign (MSParser *parser,
}
static MSNode *
node_dict (MSParser *parser,
MSNodeList *list)
{
MSNodeDict *node;
node = ms_node_dict_new (list);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_dict_entry (MSParser *parser,
const char *key,
MSNode *val)
{
MSNodeDictEntry *node;
node = ms_node_dict_entry_new (key, val);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_return (MSParser *parser,
MSNode *val)
@ -291,6 +318,36 @@ node_continue (MSParser *parser)
return MS_NODE (node);
}
static MSNode *
node_dict_elm (MSParser *parser,
MSNode *dict,
const char *key)
{
MSNodeDictElm *node;
node = ms_node_dict_elm_new (dict, key);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
static MSNode *
node_dict_assign (MSParser *parser,
MSNode *dict,
const char *key,
MSNode *val)
{
MSNodeDictAssign *node;
node = ms_node_dict_assign_new (dict, key, val);
_ms_parser_add_node (parser, node);
return MS_NODE (node);
}
%}
%name-prefix="_ms_script_yy"
@ -309,7 +366,8 @@ node_continue (MSParser *parser)
%type <node> program stmt stmt_or_python
%type <node> if_stmt ternary loop assignment
%type <node> simple_expr compound_expr expr variable list_elms
%type <node> simple_expr compound_expr expr variable
%type <node> list_elms dict_elms dict_entry
%token IF THEN ELSE FI
%token WHILE DO OD FOR IN
@ -374,8 +432,9 @@ expr: simple_expr
;
assignment:
IDENTIFIER '=' expr { $$ = node_assignment (parser, $1, $3); }
| simple_expr '[' expr ']' '=' expr { $$ = node_list_assign (parser, $1, $3, $6); }
IDENTIFIER '=' expr { $$ = node_assignment (parser, $1, $3); }
| simple_expr '[' expr ']' '=' expr { $$ = node_list_assign (parser, $1, $3, $6); }
| simple_expr '.' IDENTIFIER '=' expr { $$ = node_dict_assign (parser, $1, $3, $5); }
;
ternary: simple_expr '?' simple_expr ':' simple_expr { $$ = node_if_else (parser, $1, $3, $5); }
@ -408,9 +467,11 @@ simple_expr:
| variable
| '(' stmt ')' { $$ = $2; }
| '[' list_elms ']' { $$ = node_value_list (parser, MS_NODE_LIST ($2)); }
| '{' dict_elms '}' { $$ = node_dict (parser, $2 ? MS_NODE_LIST ($2) : NULL); }
| '[' expr TWODOTS expr ']' { $$ = node_value_range (parser, $2, $4); }
| IDENTIFIER '(' list_elms ')' { $$ = node_command (parser, $1, $3 ? MS_NODE_LIST ($3) : NULL); }
| simple_expr '[' expr ']' { $$ = node_list_elm (parser, $1, $3); }
| simple_expr '.' IDENTIFIER { $$ = node_dict_elm (parser, $1, $3); }
;
list_elms: /* empty */ { $$ = NULL; }
@ -418,6 +479,14 @@ list_elms: /* empty */ { $$ = NULL; }
| list_elms ',' expr { $$ = node_list_add (parser, MS_NODE_LIST ($1), $3); }
;
dict_elms: /* empty */ { $$ = NULL; }
| dict_entry { $$ = node_list_add (parser, NULL, $1); }
| dict_elms ',' dict_entry { $$ = node_list_add (parser, MS_NODE_LIST ($1), $3); }
;
dict_entry: IDENTIFIER '=' expr { $$ = node_dict_entry (parser, $1, $3); }
;
variable: IDENTIFIER { $$ = node_var (parser, $1); }
;