encyclopegia.org

Graph-structured stack

In computer science, a graph-structured stack (GSS) is a directed acyclic graph where each directed path represents a stack. The graph-structured stack is an essential part of Tomita's algorithm, where it replaces the usual stack of a pushdown automaton. This allows the algorithm to encode the nondeterministic choices in parsing an ambiguous grammar, sometimes with greater efficiency. In the following diagram, there are four stacks: {7,3,1,0}, {7,4,1,0}, {7,5,2,0}, and {8,6,2,0}. : Another way to simulate nondeterminism would be to duplicate the stack as needed. The duplication would be less efficient since vertices would not be shared. For this example, 16 vertices would be needed instead of 9. :

In computer science, a graph-structured stack (GSS) is a directed acyclic graph where each directed path represents a stack. The graph-structured stack is an essential part of Tomita's algorithm, where it replaces the usual stack of a pushdown automaton. This allows the algorithm to encode the nondeterministic choices in parsing an ambiguous grammar, sometimes with greater efficiency. In the following diagram, there are four stacks: {7,3,1,0}, {7,4,1,0}, {7,5,2,0}, and {8,6,2,0}. Another way to simulate nondeterminism would be to duplicate the stack as needed. The duplication would be less efficient since vertices would not be shared. For this example, 16 vertices would be needed instead of 9. ==Operations== GSSnode* GSS::add(GSSnode* prev, int elem) { int prevlevel = prev->level; assert(levels.size() >= prevlevel + 1); int level = prevlevel + 1; if (levels.size() == level) { levels.resize(level + 1); } GSSnode* node = findElemAtLevel(level, elem); if (node == nullptr) { node = new GSSnode(); node->elem = elem; node->level = level; levels[level].push_back(node); } node->add(prev); return node; } void GSS::remove(GSSnode* node) { if (levels.size() > node->level + 1) if (findPrevAtLevel(node->level + 1, node)) throw Exception("Can remove only from top."); for (int i = 0; i level].size(); i++) if (levels[node->level][i] == node) { levels[node->level].erase(levels[node->level].begin() + i); break; } delete node; }

References

No reference rows published for this article.

Cite this article

MLA

"Graph-structured stack." encyclopegia.org, 2022, https://encyclopegia.org/wiki/graph-structured-stack. Accessed 24 November 2026.

Chicago

"Graph-structured stack." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/graph-structured-stack.

APA

encyclopegia.org. (2022). Graph-structured stack. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/graph-structured-stack

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Speedup theorem

enwiki · references available

Crowsdell

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1076467531 · 0.5 · snapshot enwiki-001076467531

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.