Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ trait BasicUseAnalyzer extends TypeExpressionAnalyzer {
val (_, node1, _) = node
val data = node1.data
data match {
case direct : Ast.SpecConnectionGraph.Direct => visitList(a, direct.connections, connection)
case direct : Ast.SpecConnectionGraph.Direct => visitList(a, direct.connections.map(_._2), connection)
case pattern : Ast.SpecConnectionGraph.Pattern => for {
a <- qualIdentNode (interfaceInstanceUse) (a, pattern.source)
a <- visitList(a, pattern.targets, qualIdentNode(interfaceInstanceUse))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ trait TypeExpressionAnalyzer
val (_, node1, _) = node
val data = node1.data
data match {
case direct : Ast.SpecConnectionGraph.Direct => visitList(a, direct.connections, connection)
case direct : Ast.SpecConnectionGraph.Direct => visitList(a, direct.connections.map(_._2), connection)
case pattern => Right(a)
}
}
Expand Down
32 changes: 20 additions & 12 deletions compiler/lib/src/main/scala/analysis/Semantics/Connection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ case class Connection(
from: Connection.Endpoint,
/** The to endpoint */
to: Connection.Endpoint,
isUnmatched: Boolean = false
isUnmatched: Boolean = false,
/** The AST connection, with its annotations, if there is one */
astOpt: Option[Ast.Annotated[Ast.SpecConnectionGraph.Connection]] = None
) extends Ordered[Connection] {

override def toString = s"${from.toString} -> ${to.toString}"
Expand Down Expand Up @@ -158,17 +160,23 @@ case class Connection(
object Connection {

/** Constructs a connection from an AST connection */
def fromAst(a: Analysis, connection: Ast.SpecConnectionGraph.Connection):
Result.Result[Connection] =
for {
from <- Endpoint.fromAst(a, connection.fromPort, connection.fromIndex)
to <- Endpoint.fromAst(a, connection.toPort, connection.toIndex)
connection <- Right(Connection(from, to, connection.isUnmatched))
_ <- connection.checkDirections
_ <- connection.checkTypes(a)
_ <- connection.checkSerialWithTypedInput(a)
}
yield connection
def fromAst(
a: Analysis,
aConnection: Ast.Annotated[Ast.SpecConnectionGraph.Connection]
): Result.Result[Connection] = {
val connection = aConnection._2
for {
from <- Endpoint.fromAst(a, connection.fromPort, connection.fromIndex)
to <- Endpoint.fromAst(a, connection.toPort, connection.toIndex)
connection <- Right(
Connection(from, to, connection.isUnmatched, Some(aConnection))
)
_ <- connection.checkDirections
_ <- connection.checkTypes(a)
_ <- connection.checkSerialWithTypedInput(a)
}
yield connection
}

/** A connection endpoint */
case class Endpoint(
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/src/main/scala/ast/Ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ object Ast {

final case class Direct(
name: Ident,
connections: List[Connection]
connections: List[Annotated[Connection]]
) extends SpecConnectionGraph

object Pattern {
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/src/main/scala/codegen/AstWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ object AstWriter extends AstVisitor with LineUtils {
}
lines("spec connection graph direct") ++ (
ident(g.name) ++
g.connections.flatMap(connection)
g.connections.flatMap { case (pre, c, post) => annotate(pre, connection(c), post) }
).map(indentIn)
}
def pattern(g: Ast.SpecConnectionGraph.Pattern) = {
Expand Down
6 changes: 5 additions & 1 deletion compiler/lib/src/main/scala/codegen/FppWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ class FppWriter(a: Analysis = Analysis()) extends AstVisitor with LineUtils {
def direct(scg: Ast.SpecConnectionGraph.Direct) =
lines(s"connections ${ident(scg.name)}").
joinNoIndent (" ") (
addBraces(scg.connections.flatMap(connection))
addBraces(
scg.connections.flatMap { case (pre, c, post) =>
annotate(pre, connection(c), post)
}
)
)
def pattern(scg: Ast.SpecConnectionGraph.Pattern) = {
Line.addPrefix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object TopologyXmlFppWriter extends LineUtils {
for (connections <- connectionList(file))
yield (
Nil,
Ast.SpecConnectionGraph.Direct("XML", connections),
Ast.SpecConnectionGraph.Direct("XML", connections.map(c => (Nil, c, Nil))),
Nil
)

Expand Down
5 changes: 3 additions & 2 deletions compiler/lib/src/main/scala/syntax/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,10 @@ object Parser extends Parsers {

def specConnectionGraph: Parser[Ast.SpecConnectionGraph] = {
def directGraph = {
(connections ~> ident) ~! (lbrace ~>! elementSequence(
(connections ~> ident) ~! (lbrace ~>! annotatedElementSequence(
connection,
comma
comma,
{ case x => x }
) <~! rbrace) ^^ { case ident ~ connections =>
Ast.SpecConnectionGraph.Direct(ident, connections)
}
Expand Down
9 changes: 8 additions & 1 deletion compiler/lib/src/main/scala/transform/ExpandTemplates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,14 @@ object ExpandTemplates extends AstUnitTransformer

data match {
case data @ Ast.SpecConnectionGraph.Direct(_, connections) =>
for (connections <- transformList(a, connections, connection))
def annotatedConnection(
a: Analysis,
aConnection: Ast.Annotated[Ast.SpecConnectionGraph.Connection]
) = {
val (pre, c, post) = aConnection
for (pair <- connection(a, c)) yield ((), (pre, pair._2, post))
}
for (connections <- transformList(a, connections, annotatedConnection))
yield {
val dataCopy = data.copy(connections = connections)
val node = cloneAnnotatedNode(a, aNode, dataCopy)
Expand Down
2 changes: 2 additions & 0 deletions compiler/tools/fpp-syntax/test/syntax-ast.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,13 @@ def module
@ Direct connection graph specifier
spec connection graph direct
ident C
@ Connection
connection
from port qual ident i1.p
index literal int 0
to port qual ident i2.p
index literal int 1
@< Connection
unmatched connection
from port qual ident i1.p1
index literal int 0
Expand Down
2 changes: 2 additions & 0 deletions compiler/tools/fpp-syntax/test/syntax-include-ast.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,13 @@ def module
@ Direct connection graph specifier
spec connection graph direct
ident C
@ Connection
connection
from port qual ident i1.p
index literal int 0
to port qual ident i2.p
index literal int 1
@< Connection
unmatched connection
from port qual ident i1.p1
index literal int 0
Expand Down
2 changes: 2 additions & 0 deletions compiler/tools/fpp-syntax/test/syntax-stdin.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,13 @@ def module
@ Direct connection graph specifier
spec connection graph direct
ident C
@ Connection
connection
from port qual ident i1.p
index literal int 0
to port qual ident i2.p
index literal int 1
@< Connection
unmatched connection
from port qual ident i1.p1
index literal int 0
Expand Down
2 changes: 2 additions & 0 deletions compiler/tools/fpp-syntax/test/syntax.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ module DefinitionsAndSpecifiers {

@ Direct connection graph specifier
connections C {
@ Connection
i1.p[0] -> i2.p[1]
@< Connection
unmatched i1.p1[0] -> i2.p2[0]
unmatched i1.p1 -> i2.p2
.i1.p3 -> .i2.p3
Expand Down
3 changes: 2 additions & 1 deletion compiler/tools/fpp-to-fpp/test/include.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ module DefinitionsAndSpecifiers {

@ Direct connection graph specifier
connections C {
i1.p[0] -> i2.p[1]
@ Connection
i1.p[0] -> i2.p[1] @< Connection
unmatched i1.p1[0] -> i2.p2[0]
unmatched i1.p1 -> i2.p2
.i1.p3 -> .i2.p3
Expand Down
3 changes: 2 additions & 1 deletion compiler/tools/fpp-to-fpp/test/no_include.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ module DefinitionsAndSpecifiers {

@ Direct connection graph specifier
connections C {
i1.p[0] -> i2.p[1]
@ Connection
i1.p[0] -> i2.p[1] @< Connection
unmatched i1.p1[0] -> i2.p2[0]
unmatched i1.p1 -> i2.p2
.i1.p3 -> .i2.p3
Expand Down
6 changes: 5 additions & 1 deletion compiler/tools/fpp-to-fpp/test/topology.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ topology T implements I1,I2{

port p2 = i1.p2

connections Conn { i1.pOut -> i2.pIn }
connections Conn {
@ Connection
i1.pOut -> i2.pIn @< Connection
i2.pOut -> i1.pIn
}
}
4 changes: 3 additions & 1 deletion compiler/tools/fpp-to-fpp/test/topology.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ topology T implements \
port p2 = i1.p2

connections Conn {
i1.pOut -> i2.pIn
@ Connection
i1.pOut -> i2.pIn @< Connection
i2.pOut -> i1.pIn
}

}
5 changes: 4 additions & 1 deletion docs/fpp-spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -11091,6 +11091,9 @@ <h4 id="Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">14.2.1
<p>A <a href="#Specifiers">specifier</a>.</p>
</li>
<li>
<p>A <a href="#Specifiers_Connection-Graph-Specifiers">connection in a direct graph specifier</a>.</p>
</li>
<li>
<p>A <a href="#State-Machine-Behavior-Elements_State-Definitions_Syntax">state definition member</a>.</p>
</li>
<li>
Expand Down Expand Up @@ -14610,7 +14613,7 @@ <h3 id="Analysis-and-Translation_Translation-Tools">25.4. Translation Tools</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2026-11-19 19:46:17 -0800
Last updated 2026-12-03 13:32:49 -0800
</div>
</div>
<script src="code-prettify/run_prettify.js"></script>
Expand Down
15 changes: 14 additions & 1 deletion docs/fpp-users-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -11291,6 +11291,19 @@ <h4 id="Defining-Topologies_Connection-Graphs_Direct-Graph-Specifiers">14.2.1. D
</div>
</div>
<div class="paragraph">
<p>The connections in a direct graph specifier are
<a href="#Writing-Comments-and-Annotations_Annotations">annotatable elements</a>.
For example, you can write this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code data-lang="fpp">connections C {
@ This is a pre-annotation
a.p -&gt; b.p @&lt; This is a post-annotation
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The connections appearing in direct graph specifiers must obey the
following rules:</p>
</div>
Expand Down Expand Up @@ -18420,7 +18433,7 @@ <h3 id="Writing-C-Plus-Plus-Implementations_Serialization-of-FPP-Values">19.4. S
</div>
<div id="footer">
<div id="footer-text">
Last updated 2026-11-05 08:08:24 -0800
Last updated 2026-12-03 13:32:58 -0800
</div>
</div>
<script src="code-prettify/run_prettify.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.23">
<meta name="generator" content="Asciidoctor 2.0.26">
<title>F Prime Prime (FPP)</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<style>
Expand Down Expand Up @@ -116,7 +116,6 @@
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
pre>code{display:block}
pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
em em{font-style:normal}
strong strong{font-weight:400}
Expand Down Expand Up @@ -219,6 +218,7 @@
.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
.listingblock>.content{position:relative}
.listingblock pre>code{display:block}
.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
.listingblock:hover code[data-lang]::before{display:block}
.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
Expand Down Expand Up @@ -464,7 +464,7 @@ <h1>F Prime Prime (FPP)</h1>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2025-09-26 15:59:43 -0700
Last updated 2026-11-16 16:16:46 -0800
</div>
</div>
</body>
Expand Down
2 changes: 2 additions & 0 deletions docs/spec/Comments-and-Annotations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Annotations can occur at the following syntax elements:

* A <<Specifiers,specifier>>.

* A <<Specifiers_Connection-Graph-Specifiers,connection in a direct graph specifier>>.

* A <<State-Machine-Behavior-Elements_State-Definitions_Syntax,state definition member>>.

* A <<Template-Parameter-Lists,template parameter>>.
Expand Down
12 changes: 12 additions & 0 deletions docs/users-guide/Defining-Topologies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ For example, you can write this:
connections C { a.p -> b.p, c.p -> d.p }
--------

The connections in a direct graph specifier are
<<Writing-Comments-and-Annotations_Annotations,annotatable elements>>.
For example, you can write this:

[source,fpp]
--------
connections C {
@ This is a pre-annotation
a.p -> b.p @< This is a post-annotation
}
--------

The connections appearing in direct graph specifiers must obey the
following rules:

Expand Down
Loading