GithubHelp home page GithubHelp logo

Comments (7)

goccmack avatar goccmack commented on May 27, 2024 1

Hi Ed,

I have so far only used gogll for domain specific languages in which I write the program in a markdown file in the spirit of Don Knuth's web and weave. I have intended to add ignored tokens to the lexer specification (in the style of github.com/goccmack/gocc). That would allow you to specify tokens to be suppressed by the lexer.

Your suggestion of providing a custom function in lexer.New() is elegant and very a simple change to gogll. But perhaps it is inconvenient to deal with lexical issues outside the grammar specification.

I find specifying every place in the grammar where comments are allowed obfuscates the grammar, unless you need the comments for code generation.

What are your thoughts on the alternatives? If you need this urgently I can quickly add the custom function to lexer.New() and return to suppressed tokens later.

from gogll.

goccmack avatar goccmack commented on May 27, 2024 1

@EdSchouten
gogll v3.2.0 supports token suppression by the generated lexer. See gogll.md for details.

This can be used to implement code comments.

from gogll.

goccmack avatar goccmack commented on May 27, 2024 1

from gogll.

EdSchouten avatar EdSchouten commented on May 27, 2024

I was merely using gogll as an experiment to keep myself busy on a Sunday. There’s no need to implement anything quickly just for me. I’m happy with the solution that you think is best!

from gogll.

goccmack avatar goccmack commented on May 27, 2024

OK. Having thought about it I still prefer suppressed tokens because it keeps the complete lexical specification in one place. I will implement it as soon as I have the time.

from gogll.

EdSchouten avatar EdSchouten commented on May 27, 2024

Nice! I've just given it a try and it seems to work. One limitation that I've noticed is that the provided example:

!block_comment : '/''*' {not "*"} '*''/' ;

doesn't allow parsing these kinds of comments that you often see in C-like programming languages:

/*
 * This is a block comment.
 */

I guess that a non-greedy matching operator (a la regex .*?) is needed to support constructs like those.

from gogll.

goccmack avatar goccmack commented on May 27, 2024

from gogll.

Related Issues (15)

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.