johnlumley / jwiXML

An iXML processor for JavaScript and SaxonJS
MIT License
13 stars 0 forks source link

Bug in formatting on https://johnlumley.github.io/jwiXML.xhtml #9

Open josephcourtney opened 7 months ago

josephcourtney commented 7 months ago

First, thank you for this tool. It makes developing a iXML grammars much more convenient.

I apologize if this is not the write place for this, but I have found what I think is a bug in the format function on https://johnlumley.github.io/jwiXML.xhtml. I don't know if its origin is within jwiXML or the website-specific code. My JavaScript is limited.

Minimal Example

Given a rule: letter_list: letter++(s,-",",s).

If you click the "format" button, it will be transformed to: letter_list: letter++s,-",",s.

which removes the parentheses around the separator, and is not syntactically equivalent.

Work-around

The separator pattern can be moved into its own non-terminal to avoid the problem.

 letter_list: letter++_comma_. 
    -_comma_: s,-",",s. 

Context

Here is a full, working grammar including the affected rule in question:

 letter_list: letter++(s,-",",s). 
          -s: whitespace*. 
         -RS: whitespace+. 
 -whitespace: -[Zs;#9]. 
     -letter: [L].
johnlumley commented 7 months ago

Thanks - will look at this…. I’m due to do an update soon anyway. Glad you find the tool useful… and do let us know what applications you’re using iXML for - the community group is very eager to find out the applicability.

John Lumley

Sent from my iPad

On 2 Feb 2024, at 14:22, Joseph Courtney @.***> wrote:

 First, thank you for this tool. It makes developing a iXML grammars much more convenient.

I apologize if this is not the write place for this, but I have found what I think is a bug in the format function on https://johnlumley.github.io/jwiXML.xhtml. I don't know if its origin is within jwiXML or the website-specific code. My JavaScript is limited.

Minimal Example

Given a rule: letter_list: letter++(s,-",",s).

If you click the "format" button, it will be transformed to: letter_list: letter++s,-",",s.

which removes the parentheses around the separator, and is not syntactically equivalent.

Work-around

The separator pattern can be moved into its own non-terminal to avoid the problem.

letter_list: letter++comma. -comma: s,-",",s. Context

Here is a full, working grammar including the affected rule in question:

letter_list: letter++(s,-",",s). -s: whitespace*. -RS: whitespace+. -whitespace: -[Zs;#9]. -letter: [L]. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

josephcourtney commented 7 months ago

I am an experimental scientist by training. Specifically I work in the field of NMR spectroscopy which has many, many file formats, a lot of which are only supported by single programs.

This specific application is describing a vendor-specific programming language without a published standard. The jwiXML workbench has been very helpful since building a grammar from sample code is a trial-and-error-heavy process. I have also been using CoffeePot for automated testing.

johnlumley commented 7 months ago

Thank you - glad my and Norm Tovey-Walsh’s software has proved useful

John

Sent from my iPad

On 2 Feb 2024, at 16:02, Joseph Courtney @.***> wrote:

 I am an experimental scientist by training. Specifically I work in the field of NMR spectroscopy which has many, many file formats, a lot of which are only supported by single programs.

This specific application is describing a vendor-specific programming language without a published standard. The jwiXML workbench has been very helpful since building a grammar from sample code is a trial-and-error-heavy process. I have also been using CoffeePot for automated testing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

johnlumley commented 7 months ago

I have managed to fix the reformatting bug. Hope to get a new version on my GitHub early next week. Will let you know when done.

John

Sent from my iPad

On 2 Feb 2024, at 16:02, Joseph Courtney @.***> wrote:

 I am an experimental scientist by training. Specifically I work in the field of NMR spectroscopy which has many, many file formats, a lot of which are only supported by single programs.

This specific application is describing a vendor-specific programming language without a published standard. The jwiXML workbench has been very helpful since building a grammar from sample code is a trial-and-error-heavy process. I have also been using CoffeePot for automated testing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.