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
3 changes: 2 additions & 1 deletion compiler/lib/src/main/scala/codegen/AstWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ object AstWriter extends AstVisitor with LineUtils {
List.concat(
ident(data.name),
linesOpt(typeNameNode, data.typeName),
data.constants.flatMap(annotateNode(defEnumConstant))
data.constants.flatMap(annotateNode(defEnumConstant)),
linesOpt(addPrefix("default", exprNode), data.default)
).map(indentIn)
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/src/main/scala/codegen/FppWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ object FppWriter extends AstVisitor with LineUtils {
joinOpt (data.typeName) (": ") (typeNameNode).
joinNoIndent (" ") (
addBraces(data.constants.flatMap(annotateNode(defEnumConstant)))
)
).
joinOpt (data.default) (" default ") (exprNode)
}

override def defGuardAnnotatedNode(
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-format/test/include.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module DefinitionsAndSpecifiers {
X
Y
Z
}
} default X

@ Container specifier
product container C id 0x00 default priority 10 @< Container specifier
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-format/test/no_include.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module DefinitionsAndSpecifiers {
X
Y
Z
}
} default X

@ Container specifier
product container C id 0x00 default priority 10 @< Container specifier
Expand Down
1 change: 1 addition & 0 deletions compiler/tools/fpp-syntax/test/syntax-ast.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def module
ident Y
def enum constant
ident Z
default ident X
@ Container specifier
spec container
ident C
Expand Down
1 change: 1 addition & 0 deletions compiler/tools/fpp-syntax/test/syntax-include-ast.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def module
ident Y
def enum constant
ident Z
default ident X
@ Container specifier
spec container
ident C
Expand Down
1 change: 1 addition & 0 deletions compiler/tools/fpp-syntax/test/syntax-stdin.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def module
ident Y
def enum constant
ident Z
default ident X
@ Container specifier
spec container
ident C
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-syntax/test/syntax.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module DefinitionsAndSpecifiers {
type T
array A = [3] U32
struct S { x: [3] U32, y: F32, z: string }
enum E { X, Y, Z }
enum E { X, Y, Z } default X

@ Container specifier
product container C id 0x00 default priority 10
Expand Down