[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Making the Connection between Syntax and Semantics isStill

  • From: Peter Hunsberger <peter.hunsberger@gmail.com>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Mon, 20 Apr 2015 20:31:48 -0500

Re:  Making the Connection between Syntax and Semantics isStill
Any useful grammar is isomorphic to "code".

Peter Hunsberger

On Mon, Apr 20, 2015 at 5:05 PM, Costello, Roger L. <costello@mitre.org> wrote:

Hi Folks,

Problem: define a grammar for this simple data format:

                N item1 item2 ... itemN

The first value in the input is a number N which specifies the number of following items.

 

Ouch! That's not context-free. So basically you lose the entire context-free parsing toolkit.

 

Stated another way, that problem requires a connection between syntax and semantics.

 

Alas, we enter the world of black art.

 

Today the syntax-semantics connection is made by writing code. Let's illustrate how the connection is made in three different grammar languages: XML Schema 1.1, ANTLR, and BISON.

XML Schema 1.1

Use the ordinary context-free capabilities of XSD to define N and each item. Then embed XPath code into the XSD to constrain the number of items to N. Here it is:

ANTLR

Create parser and lexer rules. Embed Java code within the parser rules to constrain the number of items to N. Here it is:

BISON

Proceed as with ANTLR, except instead of embedding Java code into the parser rules, embed C code.

We want this: Reusable and Retargetable Grammars

Reusable: multiple different applications can use the same parse tree.

 

Retargetable: multiple different languages can be generated from the same grammar.

 

The requirement for reusable and retargetable grammars is code-free grammars.

Want to Make an Impact on the World?

Today it is nearly impossible to solve any non-trivial language recognition problem without embedding code into the grammar. In the example above we saw that we needed to embed XPath code in XML Schema, Java code in ANTRL, and C code in BISON. And that was for a trivial problem.

 

Want to make a huge impact on the world? Fix this problem. No more embedded code in grammars.

 

Comments?

 

/Roger

 




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.