GithubHelp home page GithubHelp logo

Comments (5)

mantkiew avatar mantkiew commented on May 27, 2024 1

We have forked bnfc and added some support (https://github.com/juodaspaulius/bnfc/). If there's interest we could guard these extension using a new command line parameter (e.g., --positions) and contribute back.

from bnfc.

gdetrez avatar gdetrez commented on May 27, 2024

I don't think that you can access the position of any node excepts token defined with the position keyword.

It could maybe be added as an option...

from bnfc.

rpglover64 avatar rpglover64 commented on May 27, 2024

That would be valuable.

from bnfc.

mantkiew avatar mantkiew commented on May 27, 2024

What we have to do currently, to address the issue is to introduce a bunch of internal constructions but these pollute our code badly....

in the original .cf file you'd have

Module.         Module ::= [Declaration] ;

but we add

Module . Module ::= [Declaration];
internal PosModule . Module ::= Span [Declaration];

where the Span is a section of the input file, i.e., ( (x1, y1), (x2, y2) ):

Pos . Pos ::= Integer Integer ;
internal PosPos . Pos ::= Span Integer Integer ;
Span . Span ::= Pos Pos ;
internal PosSpan . Span ::= Span Pos Pos ;

The nasty consequence is that in all our functions which work with AST nodes, we always have to pattern match on the original constructors (Module) and the new ones with positions (PosModule).

It is a nasty hack that adds up a lot programming and maintenance cost.

from bnfc.

jyp avatar jyp commented on May 27, 2024

What we could have is a function which computes a span from the
position-tokens within it.

On Wed, Jun 12, 2013 at 10:59 PM, Michal Antkiewicz <
[email protected]> wrote:

What we have to do currently, to address the issue is to introduce a bunch
of internal constructions but these pollute our code badly....

in the original .cf file you'd have

Module. Module ::= [Declaration] ;

but we add

Module . Module ::= [Declaration];
internal PosModule . Module ::= Span [Declaration];

where the Span is a section of the input file, i.e., ( (x1, y1), (x2, y2)
):

Pos . Pos ::= Integer Integer ;
internal PosPos . Pos ::= Span Integer Integer ;
Span . Span ::= Pos Pos ;
internal PosSpan . Span ::= Span Pos Pos ;

The nasty consequence is that in all our functions which work with AST
nodes, we always have to pattern match on the original constructors (
Module) and the new ones with positions (PosModule).

It is a nasty hack that adds up a lot programming and maintenance cost.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-19355141
.

from bnfc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.