@@ -196,7 +196,7 @@ let rec CreateType (tasParameters : TemplateParameter list) (acnTypeEncodingSpec
196
196
| asn1Parser.SEQUENCE_ TYPE -> Sequence( CreateSequenceChild tasParameters acnTypeEncodingSpec astRoot typeNode fileTokens alreadyTakenComments )
197
197
| asn1Parser.SET_ TYPE -> Sequence( CreateSequenceChild tasParameters acnTypeEncodingSpec astRoot typeNode fileTokens alreadyTakenComments )
198
198
| asn1Parser.ENUMERATED_ TYPE -> Enumerated( CreateNamedItems astRoot typeNode fileTokens alreadyTakenComments)
199
- | asn1Parser.BIT_ STRING_ TYPE -> BitString
199
+ | asn1Parser.BIT_ STRING_ TYPE -> BitString( CreateNamedBitList astRoot typeNode fileTokens alreadyTakenComments )
200
200
| asn1Parser.OCTECT_ STING -> OctetString
201
201
| asn1Parser.IA5String -> IA5String
202
202
| asn1Parser.NumericString -> NumericString
@@ -276,18 +276,19 @@ and CreateChoiceChild (tasParameters : TemplateParameter list) (chAcnTypeEncodin
276
276
| _ -> raise ( BugErrorException( " Bug in CreateChoiceChild" ))
277
277
)
278
278
279
+ and singleReference2DoubleReference ( tree : ITree ) =
280
+ let strVal = tree.GetChild( 0 ) .TextL
281
+ let modl = tree.GetAncestor( asn1Parser.MODULE_ DEF)
282
+ let modName = modl.GetChild( 0 ) .TextL
283
+ let imports = modl.GetChildrenByType( asn1Parser.IMPORTS_ FROM_ MODULE)
284
+ let importedFromModule = imports |> List.tryFind( fun imp -> imp.GetChildrenByType( asn1Parser.LID) |> Seq.exists( fun impTypeName -> impTypeName.Text = strVal.Value ))
285
+ let valToReturn =
286
+ match importedFromModule with
287
+ | Some( imp) -> ( imp.GetChild( 0 ) .TextL, strVal)
288
+ | None -> ( modName, strVal)
289
+ valToReturn
290
+
279
291
and CreateValue ( astRoot : list < ITree >) ( tree : ITree ) : Asn1Value =
280
- let singleReference2DoubleReference ( tree : ITree ) =
281
- let strVal = tree.GetChild( 0 ) .TextL
282
- let modl = tree.GetAncestor( asn1Parser.MODULE_ DEF)
283
- let modName = modl.GetChild( 0 ) .TextL
284
- let imports = modl.GetChildrenByType( asn1Parser.IMPORTS_ FROM_ MODULE)
285
- let importedFromModule = imports |> List.tryFind( fun imp -> imp.GetChildrenByType( asn1Parser.LID) |> Seq.exists( fun impTypeName -> impTypeName.Text = strVal.Value ))
286
- let valToReturn =
287
- match importedFromModule with
288
- | Some( imp) -> ( imp.GetChild( 0 ) .TextL, strVal)
289
- | None -> ( modName, strVal)
290
- valToReturn
291
292
292
293
293
294
let GetActualString ( str : string ) =
@@ -463,6 +464,28 @@ and CreateNamedItems (astRoot:list<ITree>) (tree:ITree) (fileTokens:array<IToken
463
464
let enumItes = getChildrenByType( tree, asn1Parser.NUMBER_ LST_ ITEM)
464
465
enumItes |> List.map CreateItem
465
466
467
+ and CreateNamedBitList ( astRoot : list < ITree >) ( tree : ITree ) ( fileTokens : array < IToken >) ( alreadyTakenComments : System.Collections.Generic.List < IToken >)=
468
+ let CreateNamedBit ( itemItree : ITree ) =
469
+ let itemChildren = getTreeChildren( itemItree)
470
+ match itemChildren with
471
+ | name:: vlue::_ ->
472
+ let value =
473
+ match vlue.Type with
474
+ | asn1Parser.INT ->
475
+ match vlue.BigIntL.Value >= 0 I with
476
+ | true -> IDV_ IntegerValue( vlue.BigIntL)
477
+ | false -> raise ( SemanticError( vlue.Location, " Negative values are not permitted" ))
478
+ | asn1Parser.DEFINED_ VALUE ->
479
+ match vlue.ChildCount with
480
+ | 2 -> IDV_ DefinedValue( vlue.GetChild( 0 ) .TextL, vlue.GetChild( 1 ) .TextL)
481
+ | 1 -> IDV_ DefinedValue( singleReference2DoubleReference vlue)
482
+ | _ -> raise ( BugErrorException( " Bug in CreateValue CreateNamedBit 1" ))
483
+ | _ -> raise ( BugErrorException( " Bug in CreateValue CreateNamedBit 2" ))
484
+ { NamedBit0.Name= name.TextL; _ value= value; Comments = Antlr.Comment.GetComments( fileTokens, alreadyTakenComments, fileTokens.[ itemItree.TokenStopIndex]. Line, itemItree.TokenStartIndex - 1 , itemItree.TokenStopIndex + 2 )}
485
+ | _ -> raise ( BugErrorException( " Bug in CreateNamedBitList.CreateItem" ))
486
+ let namedBits = getChildrenByType( tree, asn1Parser.NUMBER_ LST_ ITEM)
487
+ namedBits |> List.map CreateNamedBit
488
+
466
489
and CreateTimeClass ( astRoot : list < ITree >) ( tree : ITree ) ( fileTokens : array < IToken >) ( alreadyTakenComments : System.Collections.Generic.List < IToken >)=
467
490
let rec removeSpaceArountEqual ( str : string ) =
468
491
let rs = [ " =" ; " \t =" ; " \r\n =" ; " \r =" ; " \n =" ; " = " ; " =\t " ; " =\r\n " ; " =\r " ; " =\n " ]
0 commit comments