melt-umn / copper

An integrated context-aware scanner and parser generator
http://melt.cs.umn.edu/copper
GNU Lesser General Public License v3.0
17 stars 4 forks source link

XML Schema forbids grammars with multiple bridge productions #15

Closed 200sc closed 7 years ago

200sc commented 7 years ago

The BridgeProductions Schema portion demands a sequence of a single bridge production for a grammar, despite copper containing logic to handle multiple bridge productions in a grammar.

I don't know if there is a reason not to, but if there is not, a simple change to that schema would enable grammars with multiple bridge productions:

<xs:complexType>
    <xs:sequence>
        <xs:element name="ProductionRef" type="ProductionRef" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>
ericvanwyk commented 7 years ago

It would be great to fix this limitation. I always assumed this was caused on the Silver side.

August - just so you know, Patrick working in the lab this summer and did an interesting extension to ableC last spring that added Go-style concurrency operators to C.

schwerdf commented 7 years ago

The original reason for this limitation was the way we formulated the MDA theoretically, which excludes multiple bridge productions in an extension.

Besides changing the schema, I would probably have to make a change to the SAX parser to be able to parse in the additional bridge productions.

200sc commented 7 years ago

It's possible that it's silently failing or not processing the additional productions, but just this modification causes the grammar I'm testing it with to pass MDA with multiple bridge productions.

schwerdf commented 7 years ago

I can make absolutely no claims for that SAX parser when it is run on non-schema-conformant inputs. It looks like it might be parsing in all the bridge productions specified in a grammar, but you should verify this with your test grammar.

200sc commented 7 years ago

So when I build a copper_mda block that just contains this file (also here), I added a print statement here to see what bridge productions were being added, and I got the output I expected:

   [copper] Compiling 1 input file:
   [copper]     Parser_determinism_testRecieve.copper
   [copper] Adding bridge production: ext:edu_umn_cs_melt_exts_ableC_goConcurrency_concretesyntax_channel_recieveFrom_c
   [copper] Adding bridge production: ext:edu_umn_cs_melt_exts_ableC_goConcurrency_concretesyntax_channel_P_edu_umn_cs_melt_exts_ableC_goConcurrency_concretesyntax_channelChannel_cnc_sv_28_0
   [copper] Adding bridge production: ext:edu_umn_cs_melt_exts_ableC_goConcurrency_concretesyntax_channel_close_c
   [copper] Adding bridge production: ext:edu_umn_cs_melt_exts_ableC_goConcurrency_concretesyntax_channel_Select_c

But I admit I haven't worked with copper's internals before, so I don't know if that's the place I should be checking for the final tally of bridge productions seen.

schwerdf commented 7 years ago

What I was thinking was that you should set Copper to perform a dump of your test grammar, which would show what productions had been parsed into the spec. Not sure how easy this is to do through Silver.

200sc commented 7 years ago

Yes, the copperdump file has those productions, so they aren't being ignored, and the host grammar has productions that submit to multiple extension productions, but I don't know if the html copper dump lists extension bridge productions.

The grammar has a number of test files that would use all of the bridges that all pass, if that's worth anything.

ericvanwyk commented 7 years ago

Have you tried a grammar with multiple marking tokens?

Most of the grammar reorganization we've done is just to avoid multiple bridge productions but this would be a good thing to handle too.

Can the XML schema just be updated to accept multiple bridge productions intentionally instead of, it seems, by good fortune?

On Thu, Jun 8, 2017 at 3:58 PM, Patrick Stephen notifications@github.com wrote:

Yes, the copperdump file has those productions, so they aren't being ignored, and the host grammar contains references to multiple extension productions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/melt-umn/copper/issues/15#issuecomment-307225500, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOhdyoDhzDmM5So0TQHoi4xpoOMVur2ks5sCGBfgaJpZM4N0iSw .

200sc commented 7 years ago

The extension grammar that I'm testing has four bridge productions and three marking terminals, where one marking terminal has two associated productions and the others have one. The schema already accepted multiple marking terminals so I didn't change anything there.

ericvanwyk commented 7 years ago

Excellent.

On Thu, Jun 8, 2017 at 4:07 PM, Patrick Stephen notifications@github.com wrote:

The extension grammar has four bridge productions and three marking terminals. The schema already accepted multiple marking terminals so I didn't change anything there.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/melt-umn/copper/issues/15#issuecomment-307227861, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOhd_wTDHml_RbnOFE2WiIQ9OTNTWGrks5sCGKsgaJpZM4N0iSw .

schwerdf commented 7 years ago

This should be resolved with commit 8c6e1ae.