Giter Club home page Giter Club logo

Comments (6)

evankanderson avatar evankanderson commented on June 9, 2024

It also seems like you might want to allow comments before relationDeclaration, so that you can write the following:

model
  schema 1.1

type user
  relations
    # This is a bit tricky, but we want to do something fancy here.
    define member: [user#member]

This currently fails with:

Error: error running tests due to failed to transform due to 2 errors occurred:
	* syntax error at line=6, column=4: mismatched input '#' expecting 'define'

from language.

evankanderson avatar evankanderson commented on June 9, 2024

I am currently writing in a somewhat-formal style, so that my comments do not trip up the parser, but it is somewhat awkward to read.

s/I am/I'm, s/do not/don't/, and s/it is/it's/

from language.

evankanderson avatar evankanderson commented on June 9, 2024

The problem seem to be that relationDefTypeRestrictionBase uses the # character, so comment parsing is done in the grammar rather than in the lexer. Having the parsing done in the grammar means that the lexer may fail to produce a token when parsing a STRING (https://github.com/openfga/language/blob/main/OpenFGALexer.g4#L107), which prevents the parser from reaching the grammar stage.

One possible solution would be to add a COMMENT production to the lexer which tiggers on ^# or WHITESPACE '#'

from language.

evankanderson avatar evankanderson commented on June 9, 2024

(This also got tripped up by ; at the end of a line in the Apache license header

from language.

evankanderson avatar evankanderson commented on June 9, 2024

It appears that # // may be a work-around comment character, but that seems awkward.

Having CEL_COMMENT also consume the trailing newline might fix that problem, as it appears that it routes the CEL comments to a separate channel and not to the main grammar parser.

from language.

rhamzeh avatar rhamzeh commented on June 9, 2024

Thanks for raising it @evankanderson - this should be resolved now, let us know if you still encounter issues

from language.

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.