class keyword

0 views
Skip to first unread message

Mosh

unread,
Aug 6, 2010, 1:59:14 PM8/6/10
to Spark View Engine Dev
Hi,

I've been working on adding support for the Oxygene .Net language and
I'm running into problems because in Oxygene the class keyword is used
to declare anonymous types.

I think something like this should be valid

<html>
<head><title></title></head>
<body>
<a href="${Url.Action('Detail','Post',new class (Id =
1)}">SomeTitle</a>
</body>
</html>

When the markup gets to the compiler new class has become new @class,
so I get a compiler error.

In the CodeGrammar class I can see this

var availableIdentifier =
Snip(identifierOrKeyword.Unless(keyword))
.Or(Swap(Ch("class"), "@class"));

I have only just started using Spark so I'm not sure what the intent
is, so I was wondering if anybody could give me a pointer in the right
direction ? Is there someway I can still use the class keyword and not
have the @ added ?

Cheers,
John

Louis DeJardin

unread,
Aug 9, 2010, 4:13:24 PM8/9/10
to spar...@googlegroups.com
That's a csharp bias showing through... The is never used as a keyword in expressions, but is used fairly often as an anonymous object property for html elements.

You might want to run with a custom build that doesn't have that swap in it... Or if there's a way to pass the language type into the grammar class constructor some of those rules could be made to vary based on what the target language is.

Hi,

Cheers,
John

--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.


Mosh

unread,
Aug 13, 2010, 2:22:06 PM8/13/10
to Spark View Engine Dev
Hi Louis,

Thanks for the suggestions. I went with my own SyntaxProvider which
was a copy of DefaultSyntaxProvider, that allowed me to replace
MarkupGrammer with my own were I removed the .Or(Swap(Ch("class"),
"@class"));

I noticed there was also a CSharpSyntaxProvider but that doesn't
appear to be referenced anywhere. Do you think in the future syntax
providers other than the default one will be supported ?

Cheers,
John

Louis DeJardin

unread,
Aug 13, 2010, 3:15:50 PM8/13/10
to spar...@googlegroups.com
That's actually a leftover from a *long* time ago.

There was an question about using spark as a template engine to output csharp source code - but the elements that look natural in an html or xml template look really out of place in a csharp file.

So that was an example of looking into creating an entirely different cs-file-friendly syntax. That syntax wouldn't need to understand elements and attributes at all - probably based more on something that looked like specialized comments.

In the end he said the normal spark syntax worked quite well, even when mixed in with text that wasn't anything like markup, so the alternate csharp syntax remains essentially incomplete, unused, and unnecessary.

But yeah, in general, adding an alternate syntax provider is a very powerful way of taking control of the entire text-to-nodes parsing stage. You can introduce any syntax concepts you would like - and the rest of the system of node visitors recognizing special elements and attributes is still intact and runs after the syntax provider is done.

Reply all
Reply to author
Forward
0 new messages