Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve syntax of generated Turtle files #118

Closed
mchlrch opened this issue Dec 23, 2021 · 2 comments
Closed

Improve syntax of generated Turtle files #118

mchlrch opened this issue Dec 23, 2021 · 2 comments
Assignees

Comments

@mchlrch
Copy link
Member

mchlrch commented Dec 23, 2021

Improve the syntax of the generated .ttl files.

Original issue: #138

I suspect that the irregular punctuation leads to the mentioned parsing issues.

Here's the turtle spec: https://www.w3.org/TR/turtle/#sec-grammar

@nnamtug nnamtug self-assigned this Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
nnamtug added a commit that referenced this issue Feb 27, 2022
@nnamtug
Copy link
Collaborator

nnamtug commented Feb 27, 2022

The grammar of ttl has a lot of those separators like ';' in it, maybe even a postfix like '.' for the statement:

	predicateObjectList	::=	verb objectList (';' (verb objectList)?)*
	statement		::=	directive | triples '.'

When generating a segment, you are never sure whether to put a seperator. There are two approaches to fix this: lookahead or postprocessing. Lookahead is a bit annoying since you have to implement the specific logic for every feature (btw: this is unavoidable when implementing xtext formatting 2). Postprocessing on the other hand only comes with the cost of processing power - during generation phase one generates marker into the file. As soon as we are done generating, we can call the stateful context per file and execute the postprocessing, which just replaces the markers with the separator or postfix token (since these contexts are able to make the decision which one to chose).

Solution: Introducing IJoinContext, which implements postprocessing. TTL files look neat. This also replaces GlueingContext and stuff like extension 'jsonListSeparator' Therefore the generated syntax of the Json files also has improved. This solution also looks also sustainable for future changes.

For examples see *.ttl and *.json files here: how generated ttl and json files changed in this feature branch

mchlrch added a commit that referenced this issue Mar 16, 2022
@mchlrch
Copy link
Member Author

mchlrch commented Mar 16, 2022

Nice and tidy solution with the JoinContext, I like it.

Closing this.

@mchlrch mchlrch closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants