class - Parsing list of case classes -


I am quite new in Scala and I want to parse a list of case sections:

 D: Class Class D2 (C: String, D: IT) D Case Class D3 (E: IIT, F: String) enhances D Case Class D4E: String, F: String, G: IT) Expand D   

I want to parse an example of the listing [D]. A special order has been given in the list which can be explained by signaling like BNF:

  Representative (D0 -> D4 -> Representative (D2 - & gt; After OP (Representative (D3) D) 1-ND2 after D4, after each D2 1-ND3 and so on ...  

I want to type To create a list of:

  type T0 = (D0, D4, list [(D2, list [D3])])   

All solutions I have found so far ugly and polite

This is a ' = (D2, list [D3]) // Matching if in the list (D: D) :: (D4: D4) :: tail = & gt; ; Val (D2D3S, Tail 1) = Matchdie 2D3S (tail) (D, D4, D2D3S) :: Matchlist (Tail 1) Case Neal = & gt; Nil} DIF Match D2D3S (L: List [D]): (List [T1], List [D] = L Match {Case (D2: D2) :: Tail => Val (d3s, Tail1) = tail.span (_.InstanceOf [D3]) Val (Other D2D3S, Tail 2) = Matchdie 2D3S (Tail 1) ((D2, D3S) :: Other D2 D3S, Tail 2) Case L = & gt; (Nil, L) / Any D2S}

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -