[ 
https://issues.apache.org/jira/browse/SLING-7942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16623295#comment-16623295
 ] 

Bertrand Delacretaz commented on SLING-7942:
--------------------------------------------

Repoinit statements are parsed by a JavaCC parser from the grammar defined at 
https://github.com/apache/sling-org-apache-sling-repoinit-parser/blob/master/src/main/javacc/RepoInitGrammar.jjt

You are right that the design targets scripts, where separate lines help 
readability, as opposed to single statements where having to add end-of-line 
characters is not convenient.

One trick that could help in your case is having a multi-line text builder 
class with a `line(String ...line) ` method so that you can write your example 
like

{code}
repoinit.doStuff(Multi.line("set ACL on /var", "allow jcr:read for anonymous", 
"end"));
{code}

Which is a bit more convenient.

Apart from that, as I think the repoinit grammar does not use semicolons so 
far, we might expand the grammar to allow for replacing an EOL character with a 
semicolon, at least in some places so you could write {{"set ACL on /var ; 
allow jcr:read for anonymous ; end"}}

I won't have time to work on this in the next few days but If you want to try 
that, a first step is so add a {{< SEMICOLON: ";" >}} token definition after 
the COLON one in the grammar and replace {{<EOL>}} with {{(<EOL> | 
<SEMICOLON>)}} in the appropriate productions. 

The test suite of the parser is extensive, so will hopefully detect any 
breakage, and can be extended by adding or modifying pairs of {{.txt}} and 
{{-output.txt}} files under {{src/test/resources/testcases}}.

> RepoInit: language should not require newlines
> ----------------------------------------------
>
>                 Key: SLING-7942
>                 URL: https://issues.apache.org/jira/browse/SLING-7942
>             Project: Sling
>          Issue Type: New Feature
>          Components: Repoinit
>    Affects Versions: Repoinit Parser 1.2.2
>            Reporter: Jörg Hoh
>            Priority: Major
>
> At the moment the repoinit used to define the scriptlets requires newlines. 
> While this doesn't matter when dealing with full-blown models, it gets 
> cumbersome when you just want to create an instance of the 
> RepositoryInitializerFactory configuration to perform a single action (e.g. 
> setting an ACL on a path for a certain user).
> When I add such a configuration and set the scripts property to ```set ACL on 
> /var allow jcr:read for anonymous end``` the parser throws this exception:
> {noformat}
> ...
> Caused by: org.apache.sling.repoinit.parser.impl.ParseException: Encountered 
> " "allow" "allow "" at line 1, column 29.
> Was expecting:
>     "\n" ...
> {noformat}
> I can possibly find out how I can get this newline character in there (and 
> btw: defining the EOL token as "\n" is veeery problematic, there are other 
> platforms than unix!), but it's getting cumbersome to work with.
> It would be much better if the EOL tokens are optional. Don't know if that's 
> possible though.
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to