Papers
Topics
Authors
Recent
Search
2000 character limit reached

Cyclic Compilation Algorithm for Operator Precedence Grammars

Updated 10 July 2026
  • Cyclic Compilation Algorithm is a parallel parsing technique built on cyclic operator precedence grammars that remove acyclicity restrictions while preserving local parsability.
  • The method partitions input into chunks using specific precedence relations, allowing independent local parsing and conflict-free merging of parsed segments.
  • Its five-stage process—involving matrix construction, input partitioning, parallel parsing, conflict resolution, and merging—ensures scalable, efficient compilation.

The cyclic compilation algorithm is a parallel parsing and compilation method built on cyclic operator precedence grammars, an enriched form of operator precedence grammars in which the traditional acyclicity restriction on the equality precedence relation \doteq is removed while conflict-freeness is preserved. In this setting, operator precedence languages retain the local parsability property, so a code fragment enclosed within suitable boundary markers can be compiled with no knowledge of its external context, but cyclic equality also permits sentences with flat unbounded substructures and unranked syntax trees that can be naturally partitioned into chunks suitable for parallel parsing (Chiari et al., 2023).

1. Formal framework and precedence structure

Let Σ\Sigma be a finite terminal alphabet and NN a finite nonterminal set, with V=ΣNV=\Sigma\cup N. An operator grammar (O-grammar) is a context-free grammar G=(Σ,N,P,S)G=(\Sigma,N,P,S) whose productions AαA\to\alpha satisfy the operator form: in every right-hand side αV\alpha\in V^*, at least one terminal symbol is interposed between any two consecutive nonterminals. Renaming rules and ε\varepsilon-rules are forbidden, except possibly one ε\varepsilon-rule whose LHS is a start symbol not appearing on any RHS (Chiari et al., 2023).

The left and right terminal sets for ANA\in N are

Σ\Sigma0

Σ\Sigma1

Over Σ\Sigma2, with Σ\Sigma3 a delimiter not in Σ\Sigma4, the standard Floyd operator precedence relations are defined as follows. Equal precedence is

Σ\Sigma5

Takes precedence is

Σ\Sigma6

Yields precedence is

Σ\Sigma7

These relations are collected in an operator precedence matrix

Σ\Sigma8

where each cell Σ\Sigma9 records the relations holding between NN0 and NN1. The matrix is conflict-free iff NN2. A grammar is an operator precedence grammar iff its operator precedence matrix is conflict-free. The matrix is complete iff NN3, and if NN4 is nonempty then NN5.

Prior literature traditionally assumed that NN6 is acyclic over NN7, meaning that the transitive closure of NN8 is irreflexive on NN9. This implies a uniform bound on the length of rule RHSs and prevents cycles such as V=ΣNV=\Sigma\cup N0 or longer loops. The cyclic setting removes this restriction and admits equality cycles of the form

V=ΣNV=\Sigma\cup N1

provided the matrix remains conflict-free.

2. Local parsability and chain decomposition

Local parsability is formalized through chains. Given a conflict-free operator precedence matrix V=ΣNV=\Sigma\cup N2 and V=ΣNV=\Sigma\cup N3 delimiters, a simple chain is

V=ΣNV=\Sigma\cup N4

A composed chain allows interposed subchains between the equal-precedence terminals (Chiari et al., 2023).

The locality principle states that if V=ΣNV=\Sigma\cup N5 is a conflict-free OP-alphabet, V=ΣNV=\Sigma\cup N6 is any chain, and V=ΣNV=\Sigma\cup N7 is any operator precedence automaton compatible with V=ΣNV=\Sigma\cup N8, then there exists a support run in V=ΣNV=\Sigma\cup N9, written G=(Σ,N,P,S)G=(\Sigma,N,P,S)0, such that the first move is a push and the last move is a pop. The construction of that support depends only on G=(Σ,N,P,S)G=(\Sigma,N,P,S)1 and the boundary relations G=(Σ,N,P,S)G=(\Sigma,N,P,S)2 and G=(Σ,N,P,S)G=(\Sigma,N,P,S)3, not on the context surrounding G=(Σ,N,P,S)G=(\Sigma,N,P,S)4 and G=(Σ,N,P,S)G=(\Sigma,N,P,S)5 in the full input.

In operator precedence automata, configurations are triples G=(Σ,N,P,S)G=(\Sigma,N,P,S)6. If the top-of-stack symbol G=(Σ,N,P,S)G=(\Sigma,N,P,S)7 and the next input symbol at the beginning of G=(Σ,N,P,S)G=(\Sigma,N,P,S)8 satisfy G=(Σ,N,P,S)G=(\Sigma,N,P,S)9, the run must begin with a push. Inside AαA\to\alpha0, all moves are shifts along AαA\to\alpha1 links and pops when ending nested subchains. Because AαA\to\alpha2 is conflict-free, the sequence of shifts and pops generated by AαA\to\alpha3 is uniquely determined by the structure of AαA\to\alpha4 as a chain. The final symbol AαA\to\alpha5 triggers a pop from the cell AαA\to\alpha6.

This locality principle holds unchanged in cyclic operator precedence grammars. Cyclic AαA\to\alpha7 only prolongs simple-chain bodies; the support within an equal-precedence run is a loop of shift moves. The first and last moves are still push and pop determined by the surrounding yield and take relations, so locality remains valid. This is the formal basis for chunk-level independence in the cyclic compilation algorithm.

3. Cyclic grammars, regular-expression RHSs, and unranked trees

To capture unbounded flat fragments implied by equality cycles, cyclic operator precedence grammars enrich the right-hand side format with simplified regular expressions. A “AαA\to\alpha8-O-expression” is a regular expression over AαA\to\alpha9 using concatenation and Kleene plus “αV\alpha\in V^*0”, subject to the operator-form constraint and with each argument to αV\alpha\in V^*1 ending in a terminal. A cyclic O-grammar (C-OG) is an O-grammar whose productions αV\alpha\in V^*2 have RHS αV\alpha\in V^*3 that is a αV\alpha\in V^*4-O-expression. Immediate derivation is defined by αV\alpha\in V^*5 if αV\alpha\in V^*6 (Chiari et al., 2023).

In this enriched setting, equal precedence is extended to RHS languages:

αV\alpha\in V^*7

The relations αV\alpha\in V^*8 and αV\alpha\in V^*9 remain defined as usual through ε\varepsilon0 and ε\varepsilon1. A C-OG is a cyclic operator precedence grammar (C-OPG) iff its operator precedence matrix is conflict-free.

Allowing “ε\varepsilon2” in RHSs lets rules denote infinite regular sets of terminal and nonterminal patterns consistent with operator form. The implicit syntax trees become unranked: nodes can have unbounded numbers of children along an equal-precedence run. This exactly matches the intended structure of flat, associative operators or list-like constructs.

A concrete cyclic grammar over terminals ε\varepsilon3 and nonterminals ε\varepsilon4 includes schematic productions such as

  • ε\varepsilon5
  • ε\varepsilon6
  • ε\varepsilon7
  • ε\varepsilon8
  • ε\varepsilon9

with parenthesized ε\varepsilon0 generated by ε\varepsilon1 and ε\varepsilon2. In the corresponding matrix, ε\varepsilon3 and ε\varepsilon4 are equality cycles, multiplicative operators take precedence over additive ones, and ε\varepsilon5 and ε\varepsilon6 take precedence over ε\varepsilon7 and ε\varepsilon8 respectively. For the sentence

ε\varepsilon9

the parse tree has a ANA\in N0-node whose additive children are many, reflecting an unbounded flat structure governed by ANA\in N1.

4. Cyclic compilation algorithm

The cyclic compilation algorithm is a parallel parsing and compilation algorithm exploiting local parsability and equality cycles. It comprises five stages (Chiari et al., 2023).

The first stage is construction of the operator precedence matrix from a cyclic grammar ANA\in N2 whose RHSs are ANA\in N3-O-expressions. For every production ANA\in N4, the construction considers the regular language ANA\in N5. For each word ANA\in N6 and each pair of terminals ANA\in N7 that appear with at most one nonterminal between them, it adds ANA\in N8 if ANA\in N9 has a segment Σ\Sigma00 with Σ\Sigma01. Yield and take relations are computed through Σ\Sigma02 and Σ\Sigma03, and relations with Σ\Sigma04 are set using Σ\Sigma05 and Σ\Sigma06. Conflict-freeness is then checked. For regular RHSs, the algorithmic trick is to use finite normalizations: let Σ\Sigma07 be the set of bare RHSs with plus operators removed and Σ\Sigma08 the set of prefixes of strings from Σ\Sigma09 while normalizing double occurrences under Σ\Sigma10 by keeping at most two occurrences. Computing Σ\Sigma11 and Σ\Sigma12 from these finite normalizations preserves correctness while giving a finite basis for matrix construction.

The second stage is input partitioning. For input Σ\Sigma13 with Σ\Sigma14 padding, the algorithm computes precedence relations between consecutive terminals. A chunk is any maximal interval Σ\Sigma15 such that Σ\Sigma16, Σ\Sigma17, and for Σ\Sigma18, Σ\Sigma19 or the interval continues through nested subchains. Intuitively, a chunk is the body Σ\Sigma20 of a chain Σ\Sigma21. Markers such as parentheses provide obvious chunk boundaries, but equality cycles also make long equal-precedence runs available for splitting. If an equal-precedence run is extremely long, the algorithm further subpartitions it into subchunks of bounded size Σ\Sigma22, a tunable parameter. Formally, within any maximal run

Σ\Sigma23

one chooses boundaries Σ\Sigma24 with Σ\Sigma25 so that each subrun Σ\Sigma26 has length at most Σ\Sigma27.

The third stage is parallel parsing of chunks. Each chunk is parsed locally by a bottom-up operator precedence parser or an operator precedence automaton-based recognizer, starting from a push and ending at a pop, as guaranteed by the Σ\Sigma28 and Σ\Sigma29 boundaries. The chunk parser builds a partial parse forest, with unranked trees for cyclic equality runs, and uses a backward-deterministic grammar to prevent ambiguity. Synchronization points occur at chunk boundaries. Because local parsability holds, chunk parses are independent and merging only needs to inspect adjacency relations in the precedence matrix for the extreme terminals.

The fourth stage concerns determinism and conflict resolution. Determinism requires a conflict-free precedence matrix and a backward-deterministic grammar satisfying the condition that if Σ\Sigma30 and Σ\Sigma31 are both in Σ\Sigma32, then Σ\Sigma33. For cyclic Σ\Sigma34 runs, the local parser uses normalized “two-occurrence” equivalence to prevent looping ambiguity; it recognizes patterns under Σ\Sigma35 by detecting double occurrence of cycles and then compacting them. If precedence construction detects conflicts, the grammar must be revised. If chunk boundaries fall within an equal-precedence cycle, the algorithm meta-labels subchunks and merges them under a single parent node representing the operator at that precedence level.

The fifth stage is merging. Chunks are processed in input order, and merging examines only the extreme terminals of adjacent chunks. If the previous chunk’s right extreme and the next chunk’s left extreme satisfy Σ\Sigma36, the algorithm performs an equal-precedence merge, combining the partial parses under a single flat node. If they satisfy Σ\Sigma37 or Σ\Sigma38, the algorithm uses operator precedence to decide nesting and perform reductions or pops. The invariants are that each chunk parse respects operator form and precedence relations inside the chunk, merging checks only adjacency of chunk extremes via the precedence matrix and performs reductions without peeking inside chunk bodies, and after merging the frontier of the global tree equals the original input while the parse respects the matrix.

The stated complexity is as follows. Let Σ\Sigma39, Σ\Sigma40 be the number of chunks, and Σ\Sigma41 the number of processors. Building the precedence matrix is linear in grammar size and in the finite normalization of RHSs; if Σ\Sigma42 is the maximum nesting depth of Σ\Sigma43 and Σ\Sigma44 is the maximum primitive RHS length, the normalization yields Σ\Sigma45 distinct prefixes and building the matrix is Σ\Sigma46 in the worst case. Partitioning is Σ\Sigma47, with chunk splitting incurring Σ\Sigma48. Parsing chunks has total work Σ\Sigma49, since each terminal participates in Σ\Sigma50 local decisions under a conflict-free matrix, and the parallel parse time is approximately Σ\Sigma51, where Σ\Sigma52 are chunk lengths. Merging is Σ\Sigma53. Overall sequential time is Σ\Sigma54, and the parallel time is described as

Σ\Sigma55

Space usage is Σ\Sigma56 for distributed parse stacks and Σ\Sigma57 for the precedence matrix.

5. Expressive equivalences and formal correspondences

The enriched cyclic formalism is presented as fully equivalent in expressive power to other formalisms for

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Cyclic Compilation Algorithm.