- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Parser combinators: how to modify line numbering?
Tue, 2009-03-17, 02:47
I am writing a small parser for an intermediate language that also
allows for line-number directives like the # directives in
C/C++ (for reporting purposes).
Does anyone have an idea how to do that within the current
parser-combinator framework in scala?
What I want to achieve that the positioned(p) stores the modified
location instead of the original one. (Of course, the column
information will be bogus, anyways, but I want to have at least the
row right.)
Tue, 2009-03-17, 21:47
#2
Re: Parser combinators: how to modify line numbering?
It's definitely a possibility, but then it would require me to count
my lines myself, I don't see any really straightforward way to do that
(I use newline character in different lexical rules). Maybe having a
lexer below the current one is the only reliable solution.
On 3/17/09, Naftoli Gugenheim wrote:
> Why not record the real line numbers of the line number directives and store
> them in a map, and then whenever you need to display the line number look it
> up in the map?
>
>
> On Mon, Mar 16, 2009 at 9:47 PM, Christian Szegedy
> wrote:
>
> > I am writing a small parser for an intermediate language that also
> > allows for line-number directives like the # directives in
> > C/C++ (for reporting purposes).
> >
> > Does anyone have an idea how to do that within the current
> > parser-combinator framework in scala?
> >
> > What I want to achieve that the positioned(p) stores the modified
> > location instead of the original one. (Of course, the column
> > information will be bogus, anyways, but I want to have at least the
> > row right.)
> >
>
>
On Mon, Mar 16, 2009 at 9:47 PM, Christian Szegedy <christian.szegedy@gmail.com> wrote: