XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Is & a command?

In addition to Michael's comment, I think Roger is making the mistake of treating a specific for a universal.

"The [ is actually the name of the command" is not a universal statement that all [ are commands, or that all opening delimiters are commands, but a specific statement that in the particular shell they are implemented/treated/equivalent as commands. The scope of the statement is that particular language's implementation or design (and perhaps its "denotational semantics".)

It is as wrongheaded as would be "English has prepositions, so is the XML & delimiter a preposition?"

On the other hand, if Roger is asking "Is it possible to write a parser for XML in which each delimiter is used as the 'name' of a 'command' used to parse the next  section after it?"  then the answer is yes: there are several classes of parsers that can be implemented like that (e.g. some of bottom up, shift-reduce, PEG, etc.)  

Loosely, a top-down parser says "I am looking now for z, y or z" while a bottom-up parser say "I am presented now with a z: what are the ramifications?"  So in the bottom-up case, you could regard of the z as (the name of) a command, if it helped. (The threaded interpreted languages like Forth work like that, IIRC:  there is no distinct scanner, so a new command could be added just using any unique character.)

Parsers can be implemented accepting grammars, or by hardcoding, and by everything in between.  (The fundamental implementation issue is not whether a lexical token is treated as a string, a message, a method name, a command, or whatever, but whether your implementation needs a stack or not:  a stack is not required to parse XML text, but it is needed one to judge well-formedness.)

Regards
Rick



On Mon, Nov 14, 2022 at 8:53 PM Roger L Costello <costello@mitre.org> wrote:

Hi Folks,

 

In UNIX there is a command named “test” which is used like this:

 

             test expression

 

Upon encountering that, a UNIX-aware application (e.g., a UNIX shell) will call the test command to evaluate expression.

 

Interestingly, these two forms are equivalent:

 

             test expression

             [ expression ]

 

The book [1] that I am reading says this about the second form:

 

The [ is actually the name of the command
             (who said anything about command names
             having to be alphanumeric characters?). It
             still initiates execution of the same test
             command, only in this format, test expects
             to see a closing ] at the end of the expression.

 

Okay, now to XML ….

 

An XML document may contain this:

 

             &lt;

 

Upon encountering that, an XML-aware application (e.g., an XML parser) will call a routine to convert the entity. One might say this:

 

The & is actually the name of the command.
             It initiates execution of the & command and
             expects to see a closing ; at the end.

 

So, …………….

 

Is & a command?

 

Likewise, ……………..

 

Is < a command?

 

Is " a command?

 

If the answers are no, then what are they? What is the difference between a command and whatever those things are?

 

/Roger

 

[1] UNIX Shell Programming by Kochan and Wood, p. 155.



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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS