[
Lists Home |
Date Index |
Thread Index
]
Miles Sabin <miles@milessabin.com> wrote:
| Jeni Tennison mailed me offline with an excellent suggestion which I
| think significantly improves on my proposal.
|
| She pointed out that we could actually use XPath syntax directly, [...]
| which on expansion looks like this,
|
| html[
| head[
| title = 'Example 3' and
| link[@rel = 'stylesheet' and
| @type = 'text/css' and
| @uri = '/ss/style.css']] and
| body/p = 'Hello World']
|
| which, beautifully, can be used as a selector for the newly created
| element.
|
| There's a small cost in that using XPath is slightly more verbose
| (" and " rather than ","), but that's more than offset, IMO, by the fact
| that there are no syntactic innovations.
I have to agree that XPath syntax would be a winner on pragmatic grounds.
But I can't resist saying that I find the syntax somewhat cluttered. An
"operator style" syntax works just as well:
html =
head =
title = 'Example 3' ;
+ link =
rel @ 'stylesheet'
+ type @ 'text/css'
+ uri @ '/ss/style.css' ;;
+ body =
p = 'Hello World' ;;;
For which, a minimum reduced yacc spec (with 15 states) could be:
%token NAME STRING
%%
wff
: NAME '=' elembody ';'
;
elembody
: elemitem
| elemitem '+' elembody
;
elemitem
: NAME '=' elembody ';'
| NAME '@' STRING
| STRING
;
%%
|