summaryrefslogtreecommitdiff
path: root/colm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-12-27 12:33:19 +0200
committerAdrian Thurston <thurston@colm.net>2019-12-27 12:33:19 +0200
commit7c474afdd7d5ef23f1a6ea99a54db72ae86f331c (patch)
tree7510ab9532378ce07b60726be5cc68937edd429f /colm
parentba0569b4a80459e7d05f63115c89073eb9637537 (diff)
downloadragel-7c474afdd7d5ef23f1a6ea99a54db72ae86f331c.tar.gz
allow simple variable defs in colm bootstrap grammar
These are allowed, but ignored in bootstrap0 and bootstrap1. We can then use them in the rewriter to log changes we made.
Diffstat (limited to 'colm')
-rw-r--r--colm/consinit.cc31
-rw-r--r--colm/consinit.h3
2 files changed, 32 insertions, 2 deletions
diff --git a/colm/consinit.cc b/colm/consinit.cc
index 4bd6e1c6..7c719615 100644
--- a/colm/consinit.cc
+++ b/colm/consinit.cc
@@ -695,6 +695,30 @@ void ConsInit::optProdName()
definition( "opt_prod_name", prod1, prod2 );
}
+void ConsInit::prodVarDef()
+{
+ ProdEl *prodEl1 = prodRefName( "Name", "id" );
+ ProdEl *prodEl2 = prodRefLit( "':'" );
+ ProdEl *prodEl3 = prodRefName( "Type", "id" );
+ Production *prod1 = production( prodEl1, prodEl2, prodEl3 );
+
+ definition( "prod_var_def", prod1 );
+}
+
+/* The prod var list we provide in a basic form, just "id: id." We won't make
+ * use of them in bootstrap0 or bootstrap1, They are ignored in the loader for
+ * bootstrap1. We want to use them in bootstrap2 during the rewrite stage. */
+void ConsInit::prodVarList()
+{
+ ProdEl *prodEl1 = prodRefName( "VarDefList", "prod_var_list" );
+ ProdEl *prodEl2 = prodRefName( "VarDef", "prod_var_def" );
+ Production *prod1 = production( prodEl1, prodEl2 );
+
+ Production *prod2 = production();
+
+ definition( "prod_var_list", prod1, prod2 );
+}
+
void ConsInit::prod()
{
ProdEl *prodEl1 = prodRefLit( "'['" );
@@ -724,9 +748,10 @@ Production *ConsInit::prodProd()
{
ProdEl *prodEl1 = prodRefLit( "'def'" );
ProdEl *prodEl2 = prodRefName( "DefId", "id" );
- ProdEl *prodEl3 = prodRefName( "ProdList", "prod_list" );
+ ProdEl *prodEl3 = prodRefName( "ProdVarList", "prod_var_list" );
+ ProdEl *prodEl4 = prodRefName( "ProdList", "prod_list" );
- return production( prodEl1, prodEl2, prodEl3 );
+ return production( prodEl1, prodEl2, prodEl3, prodEl4 );
}
void ConsInit::item()
@@ -880,6 +905,8 @@ void ConsInit::go( long activeRealm )
prodElList();
optCommit();
optProdName();
+ prodVarDef();
+ prodVarList();
prod();
prodList();
ignore();
diff --git a/colm/consinit.h b/colm/consinit.h
index 76ccabdf..7485445c 100644
--- a/colm/consinit.h
+++ b/colm/consinit.h
@@ -93,7 +93,10 @@ struct ConsInit
void optProdElName();
void prodEl();
void prodElList();
+ void varDefList();
void item();
+ void prodVarDef();
+ void prodVarList();
void prodList();
void optProdName();
void prod();