@@ -188,31 +188,23 @@ Base.showerror(io::IO, e::ParsingError) = print(io, "Language Error: $(e.pos.l1)
188188#  construct object from tag and arguments
189189# 
190190
191- function  construct_object (lang, tag, args:: AbstractDict{<:Any,<:Any} )
191+ function  construct_object (lang, tag, args:: AbstractDict{<:Any,<:Any} ; key = nothing )
192192    if  ! ( tag in  keys (lang. objects))
193193        throw (LangUnknownTag (tag))
194194    end 
195195    constructor =  lang. objects[tag]
196196    try 
197-         return  constructor (;args... )
198-     catch  err
199-         throw ( LangInvalidCall (tag, err) )
200-     end 
201- end 
202- 
203- function  construct_object (lang, tag, args)
204-     if  ! (tag in  keys (lang. objects))
205-         throw (LangUnknownTag (tag))
206-     end 
207-     constructor =  lang. objects[tag]
208-     try 
209-         return  constructor (args... )
197+         if  key ===  nothing 
198+             return  constructor (;args... )
199+         else 
200+             vars =  tuple ((Symbol (e) for  e in  split (String (key)," ," . .. )
201+             return  constructor (vars; args... )
202+         end 
210203    catch  err
211204        throw ( LangInvalidCall (tag, err) )
212205    end 
213206end 
214207
215- # 
216208#  option types
217209#  maybe this is not needed anymore thanks to constant propagation
218210
253245
254246
255247#  sequences
256- function  eval_node (node:: YAML.SequenceNode , calibration:: AbstractDict{Symbol, <:Number} , minilang:: Language = Language (), greek_tol:: GreekTolerance = NoGreek ())
248+ function  eval_node (node:: YAML.SequenceNode , calibration:: AbstractDict{Symbol, <:Number} , minilang:: Language = Language (), greek_tol:: GreekTolerance = NoGreek (); key = nothing )
257249    children =  [eval_node (ch, calibration, minilang, greek_tol) for  ch in  node]
258250    tag =  node. tag
259251    if  tag ==  " tag:yaml.org,2002:seq" 
@@ -266,15 +258,15 @@ function eval_node(node::YAML.SequenceNode, calibration::AbstractDict{Symbol, <:
266258    else  #  custom object with positional arguments
267259        childs =  tuple (children... )
268260        try 
269-             return  construct_object (minilang, tag, childs)
261+             return  construct_object (minilang, tag, childs; key = key )
270262        catch  err
271263            throw (ParsingError (node, err))
272264        end 
273265    end 
274266end 
275267
276268#  map
277- function  eval_node (node:: YAML.MappingNode , calibration:: AbstractDict{Symbol, <:Number} , minilang:: Language = Language (), greek_tol:: GreekTolerance = NoGreek ())
269+ function  eval_node (node:: YAML.MappingNode , calibration:: AbstractDict{Symbol, <:Number} , minilang:: Language = Language (), greek_tol:: GreekTolerance = NoGreek (); key = nothing )
278270    d =  Dict ()
279271    for  i= 1 : length (node)
280272        k =  Symbol (node. value[i][1 ]. value)
@@ -294,9 +286,39 @@ function eval_node(node::YAML.MappingNode, calibration::AbstractDict{Symbol, <:N
294286        return  d
295287    else  #  custom object with positional arguments
296288        try 
297-             return  construct_object (minilang, node. tag, d)
289+             return  construct_object (minilang, node. tag, d; key = key )
298290        catch  err
299291            throw (ParsingError (node, err))
300292        end 
301293    end 
302294end 
295+ 
296+ 
297+ 
298+ function  eval_node_with_keys (node:: YAML.MappingNode , calibration:: AbstractDict{Symbol, <:Number} , minilang:: Language = Language (), greek_tol:: GreekTolerance = NoGreek ())
299+     d =  []
300+     for  i= 1 : length (node)
301+         k =  Symbol (node. value[i][1 ]. value)
302+         if  typeof (greek_tol)<: FromGreek 
303+             if  haskey (symbols_from_greek, k)
304+                 k =  symbols_from_greek[k]
305+             end 
306+         elseif  typeof (greek_tol)<: ToGreek 
307+             if  haskey (symbols_to_greek, k)
308+                 k =  symbols_to_greek[k]
309+             end 
310+         end 
311+ 
312+         v =  eval_node (node. value[i][2 ], calibration, minilang, greek_tol; key= k)
313+         push! (d, v)
314+     end 
315+     if  node. tag ==  " tag:yaml.org,2002:map" 
316+         return  d
317+     else  #  custom object with positional arguments
318+         try 
319+             return  construct_object (minilang, node. tag, d)
320+         catch  err
321+             throw (ParsingError (node, err))
322+         end 
323+     end 
324+ end 
0 commit comments