Skip to content

Commit

Permalink
Added a new structure expansion token <STRUCTURE_FIRST_UNIQUE_KEY>.
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveIves committed Jun 8, 2023
1 parent ab296ed commit 253a2c2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CodeGenEngine/TokenExpanders/TokenExpanderStructure.dbl
Expand Up @@ -87,6 +87,7 @@ namespace CodeGen.Engine
structureTokenExpanders.Add("STRUCTURE_DESC", expandStructureDesc)
structureTokenExpanders.Add("STRUCTURE_FIELDS", expandStructureFields)
structureTokenExpanders.Add("STRUCTURE_FILES", expandStructureFiles)
structureTokenExpanders.Add("STRUCTURE_FIRST_UNIQUE_KEY", expandStructureFirstUniqueKey)
structureTokenExpanders.Add("STRUCTURE_KEYS", expandStructureKeys)
structureTokenExpanders.Add("STRUCTURE_LDESC", expandStructureLongDescription)
structureTokenExpanders.Add("STRUCTURE_NAME", expandStructureName)
Expand Down Expand Up @@ -667,6 +668,23 @@ namespace CodeGen.Engine
mreturn ExpandStructureToken(tkn, template, loops, doExpand)
endmethod

private static method expandStructureFirstUniqueKey, string
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
endparams
proc
lambda doExpand(str)
begin
data thekey, @RpsKey, str.Keys.FirstOrDefault(lambda (k) {k.Duplicates == RpsKeyDuplicates.NoDuplicates})
if (thekey == ^null) then
mreturn ""
else
mreturn thekey.KeyOfReference.ToString()
end
mreturn ExpandStructureToken(tkn, template, loops, doExpand)
endmethod

private static method expandStructureKeys, string
tkn, @Token
template, @FileNode
Expand Down
1 change: 1 addition & 0 deletions CodeGenEngine/Tokenizer.dbl
Expand Up @@ -261,6 +261,7 @@ namespace CodeGen.Engine
& { new TokenMeta() {Name = "STRUCTURE_DESC", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { new TokenMeta() {Name = "STRUCTURE_FIELDS", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { new TokenMeta() {Name = "STRUCTURE_FILES", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { new TokenMeta() {Name = "STRUCTURE_FIRST_UNIQUE_KEY", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { new TokenMeta() {Name = "STRUCTURE_KEYS", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { new TokenMeta() {Name = "STRUCTURE_LDESC", TypeOfToken = TokenType.StructureInfo, IsPaired = false, Validity = TokenValidity.Anywhere, RequiresRepository = true} },
& { makeTokenMeta_AllVariants("STRUCTURE_NAME", TokenType.StructureInfo, TokenValidity.Anywhere, true) },
Expand Down
Binary file modified Documentation/CodeGen.chm
Binary file not shown.
Binary file modified Documentation/CodeGen.hsmx
Binary file not shown.

0 comments on commit 253a2c2

Please sign in to comment.