Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is scala.util.parsing.ast.Binders supposed to be used?

I am currently implementing a small compiler in Scala and while I was doing the component for context analysis I discovered the trait Binders in package scala.util.parsing.ast (I am using Scala 2.9 RC), which is Documented to enable name binding during parse time. That sounds very interesting and I have been googling around a lot, but I still have no clue how to use it. While I am of course able to let my abstract syntax derrive from Binders I dont see how to proceed from there. Are there any examples of the usage on the net?

like image 762
Martin Ring Avatar asked Oct 11 '22 05:10

Martin Ring


2 Answers

By googling a bit I found this page, which seems to be a development version of a documentation with more details. Unfortunately I was not able to find online (I mean, outside a source repository) version of these documentations.

I'm not sure however that you will find what you're looking for in this library. Name resolution is a rather delicate thing, and it smells like a questionable idea to do it during parsing. The documentation of this library itself highlights that it is only suitable for languages where the name resolution is relatively simple, and may not scale otherwise. Besides, none of the parsing examples in the Scala repository make use of this class.

I would cautiously avoid this uncharted territory, and design binding analysis in a separate post-parsing pass.

like image 151
gasche Avatar answered Oct 31 '22 22:10

gasche


You're not supposed to use it. In fact, it has recently been deprecated.

See deprecation candidate: scala.parsing.ast

like image 35
iron9light Avatar answered Oct 31 '22 21:10

iron9light