Expand description
Module-level pragmas for Polydat source.
Pragmas are first-class Polydat statements the module author places at
the head of a .polydat file or module body to opt into compile-time
graph transforms. Today they cover assertion-injection modes that
complement the const-constraint metadata (SRD 15):
pragma strict_values
pragma strict_types
pragma strict // convenience alias for both
id := mod(hash(cycle), 1000)pragma is a reserved keyword in the Polydat grammar; pragmas are
Statement::Pragma in the AST and walked by the compiler the
same way other statements are. They’re not comments — distinct
syntactic construct, distinguishable from ///# line comments.
§Recognised pragma names
strict_types— auto-insert type assertion nodes on wires whose source can’t be statically proven to deliver the rightPortType. See SRD 15 §“Strict Wire Mode”.strict_values— auto-insert value assertion nodes on wires whose downstream node declares a value constraint the source can’t satisfy at compile time.strict— alias for bothstrict_types+strict_values.
Unknown pragmas are recorded but warned about, not errored: pragmas are forward-compatible by design so old binaries can parse modules that opt into newer features they don’t yet support.
§Scoping (SRD 15 §“Pragma Scope”)
Each Polydat program has its own PragmaSet, collected once at
the root by collect_from_ast. Inner contexts inherit the outer
scope’s pragmas: a for body compiles under a clone of its
parent’s set, so an enclosing strict_values applies to every
nested body. PragmaSet::attach_to and PragmaConflict
model a parent chain with outer-wins conflict resolution; the
compiler does not use them today.
Structs§
- Pragma
- One pragma entry parsed from the source.
- Pragma
Conflict - A pragma that disagreed across nested scopes. Used by
PragmaSet::attach_toto surface conflicts up to the caller for either advisory logging (non-strict) or hard error (strict). Per SRD 15 §“Pragma Scope” + SRD 13b §“Scope composition”, the outer scope’s value wins; the conflict report is for diagnostics, not for resolution. - Pragma
Set - All pragmas declared in one Polydat scope. Multiple
PragmaSets chain through theirparentfield, set byPragmaSet::attach_to, to model nested scopes (program →forbody). Per SRD 13b §“Scope composition” + SRD 15 §“Pragma Scope”: each scope is its ownPragmaSet, the chain is walked at lookup time, and outer scopes win on conflict.
Functions§
- collect_
from_ ast - Walk a parsed AST and collect every
Statement::Pragmainto aPragmaSet. This is the canonical extraction path — pragmas are first-class grammar (thepragmakeyword) and the parser produces them as proper statements.