I think the best way to describe it is by showing those cases. That should
illustrate my answer to Tim.

You can find all the sample Jelly strings here:
https://github.com/glasswalk3r/jenkins-translation-tool/tree/refactor/jelly_parser/t/samples
.

This is an ad hoc set of files: first I started just copying the files that
the parser missed (compared results between this branch parser and the
original parser from the main branch), then I started copying entire lines
from other Jelly files. You can expect that the XML is OK, but messages
might be out of context (and I guess that doesn't matter).

Here is the easiest way to find out where I stopped in the validation
processes:

$ git branch
  main
* refactor/jelly_parser
$ prove -lvm t/load_jelly.t
t/load_jelly.t ..
# Using t/samples/message.jelly
ok 1 - result is a hash reference
ok 2 - result has the expected content
# Using sample t/samples/config.jelly
ok 3 - result is a hash reference
ok 4 - result has the expected content
# Using sample t/samples/signup.jelly
ok 5 - result is a hash reference
ok 6 - result has the expected content
# Using sample t/samples/oops.jelly
ok 7 - result is a hash reference
ok 8 - result has the expected content
# Using sample t/samples/manage.jelly
ok 9 - result is a hash reference
not ok 10 - result has the expected content

#   Failed test 'result has the expected content'
#   at t/load_jelly.t line 93.
#     Structures begin differing at:
#          $got->{updateAvailable} = Does not exist
#     $expected->{updateAvailable} = '1'
# {
#   'Manage\\ Jenkins' => 1,
#   'are.you.sure' => 1,
#   'updateAvailable(m.getUpdateCount())\'\\ \\:\\ \'' => 1,
#   'updatesAvailable(m.getUpdateCount())\'' => 1
# }
1..10
# Looks like you failed 1 test of 10.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/10 subtests

Test Summary Report
-------------------
t/load_jelly.t (Wstat: 256 (exited 1) Tests: 10 Failed: 1)
  Failed test:  10
  Non-zero exit status: 1
Files=1, Tests=10,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.09 cusr
 0.00 csys =  0.11 CPU)
Result: FAIL
$

This is the line causing me trouble:

<div tooltip="${m.getUpdateCount() == 1 ?
'%updateAvailable(m.getUpdateCount())' :
'%updatesAvailable(m.getUpdateCount())'}"
class="jenkins-section__item__icon__badge">

Supposedly the XML parser is getting the tooltip text as expected, but the
rest I would need to do an additional effort to parse properly.

Maybe this is a section that I shouldn't bother at all. Maybe a review is
needed in all samples available.

The thing is, even with this current failure, the experimental parser is
already getting Jelly translation "segments" that are not identified by the
original parser (from the main branch).

On Fri, Aug 26, 2022 at 8:28 AM 'Daniel Beck' via Jenkins Developers <
jenkinsci-dev@googlegroups.com> wrote:

>
>
> On Wed, Aug 24, 2022 at 6:29 PM Alceu Rodrigues de Freitas Junior <
> alceu.freitas...@gmail.com> wrote:
>
>> I've being working in a CLI to parse the properties and Jelly files from
>> the Jenkins project, in order to help the translation process from English
>> to other languages.
>>
>> The project is here:
>> https://github.com/glasswalk3r/jenkins-translation-tool.
>>
>> The CLI is still using regular expressions for the Jelly parsing and I've
>> struggling to replace that with proper parsers.
>>
>> I partially reached that by introducing a XML parser and then extracting
>> the Jelly strings.
>>
>> The thing is, Jelly is complex enough that regular expression are still
>> not good enough for parsing: I keep finding corner cases that are not being
>> covered by an already complex regular expressions.
>>
>> I decided that is time to stop and try to build a proper grammar to parse
>> Jelly.
>>
>
> Out of curiosity, what are some of the corner cases that cause problems?
> How common are they?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7Pt%2BTjm6vWadirx4km27mwk%2BLM65mYdcXvT6fBkZOSa9nBA%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7Pt%2BTjm6vWadirx4km27mwk%2BLM65mYdcXvT6fBkZOSa9nBA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAKxtECovODVQXBSEAFYytkzV9yRWSV_88Q4YSyESYmepkxtg_A%40mail.gmail.com.

Reply via email to