summaryrefslogtreecommitdiff
path: root/src/InadequacyList.c
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny@ces.clemson.edu>2009-04-21 02:10:57 -0400
committerJoel E. Denny <jdenny@ces.clemson.edu>2009-04-21 05:59:36 -0400
commit7fe11bb55c1ca7e08f392b8bf413d18062019dd3 (patch)
treeb488a6ed641b6f47dca42fa89eb9a28feef04f77 /src/InadequacyList.c
parent7254f6a84048d56da7b004c2934613f7f9de391a (diff)
downloadbison-7fe11bb55c1ca7e08f392b8bf413d18062019dd3.tar.gz
Add new files for IELR and canonical LR implementation.
* src/AnnotationList.c: New. * src/AnnotationList.h: New. * src/InadequacyList.c: New. * src/InadequacyList.h: New. * src/Sbitset.c: New. * src/Sbitset.h: New. * src/ielr.c: New. * src/ielr.h: New.
Diffstat (limited to 'src/InadequacyList.c')
-rw-r--r--src/InadequacyList.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/InadequacyList.c b/src/InadequacyList.c
new file mode 100644
index 00000000..edf3a0f5
--- /dev/null
+++ b/src/InadequacyList.c
@@ -0,0 +1,76 @@
+/* IELR's inadequacy list.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ This file is part of Bison, the GNU Compiler Compiler.
+
+ 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include "system.h"
+
+#include "InadequacyList.h"
+
+ContributionIndex const ContributionIndex__none = -1;
+ContributionIndex const ContributionIndex__error_action = -2;
+
+InadequacyList *
+InadequacyList__new_conflict (state *manifesting_state, symbol *token,
+ bitset actions)
+{
+ InadequacyList *result = xmalloc (sizeof *result);
+ result->next = NULL;
+ result->manifestingState = manifesting_state;
+ result->contributionCount = bitset_count (actions);
+ result->inadequacy.conflict.token = token;
+ result->inadequacy.conflict.actions = actions;
+ return result;
+}
+
+void
+InadequacyList__delete (InadequacyList *self)
+{
+ while (self)
+ {
+ InadequacyList *node = self;
+ self = self->next;
+ bitset_free (node->inadequacy.conflict.actions);
+ free (node);
+ }
+}
+
+ContributionIndex
+InadequacyList__getShiftContributionIndex (InadequacyList const *self)
+{
+ if (!bitset_test (self->inadequacy.conflict.actions,
+ self->manifestingState->reductions->num))
+ return ContributionIndex__none;
+ return self->contributionCount - 1;
+}
+
+symbol *
+InadequacyList__getContributionToken (InadequacyList const *self,
+ ContributionIndex i)
+{
+ aver (0 <= i && i < self->contributionCount);
+ return self->inadequacy.conflict.token;
+}
+
+void
+InadequacyList__prependTo (InadequacyList *self, InadequacyList **list)
+{
+ InadequacyList *head_old = *list;
+ *list = self;
+ self->next = head_old;
+}