Comments (6)
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.
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.
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.
(This also got tripped up by ;
at the end of a line in the Apache license header
from language.
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.
Thanks for raising it @evankanderson - this should be resolved now, let us know if you still encounter issues
from language.
Related Issues (20)
- In transformer folder, create a new folder called `module-to-json.(ts|go)`, it it create a new function that allows passing in multiple files with their contents `transformModuleFiles(files: { name, contents }[]): AuthorizationModel`, this would handle normal transformation of each file + additional validation
- In `module-to-json.(ts|go)`, add a `transformModFileToJSON` that parses the `fga.mod` yaml and ensures the file is valid
- Add a JSON Schema for what the JSON model should look like and validate against invalid JSON input
- mark generated files as generated in git
- Language is validating against valid cases where `this` is not in first place
- Allow using keywords as relation, type and condition names HOT 2
- Issues in validation of fga.mod fields HOT 3
- When transforming a modular model back to DSL, specify module in comments
- Import all the server tests and make sure they pass validation here HOT 1
- Move over relevant typesystem tests from the server to language
- Map errors raised by `validateJSON` back to their original source files HOT 1
- Improve validation when transforming modules
- Allow providing schema version in transformModuleFilesToModel
- Ensure that every file referenced in the `fga.mod` is in the current or sub-directory
- add methods to validate types, relations, ids and tuples
- detect-non-literal-regexp
- Wrong error message thrown when the base relation used in the from contains a rewrite
- Incorrect line for type when looking up the typeIndex, when type is a substring HOT 1
- Validation location errors found in java implementation HOT 1
- Set up the multi-package publishing process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language.