Re: [Google Groups] Allowing a different language within a language

57 views
Skip to first unread message

Dave Dolan

unread,
Feb 2, 2013, 4:16:10 PM2/2/13
to gold-pars...@googlegroups.com
'embedded langauge' parsers like say aspx pages which are both html and c# or whatever, usually will actually convert all of it into one or the other with two parser passes.  One pass with a parser that recogizes the html and ignores the C# and one that recognizes the c#

For example, in aspx they first pass over the html and convert it to something like this in C#, Response.Write("<table><myTableStuff>") then the C# is passed off to the regular old compiler. 

PHP and ruby on rails both use similar techniques.


On Thu, Jan 24, 2013 at 3:23 PM, Leho Na <leon.vo...@uni-oldenburg.de> wrote:
Basically I'm currently writing a grammar for a very concise line based language that will help developers write dialogues for a certain game engine, because the original language (Let's call it Daedalus) is really messy for this purpose. 
However, I want to allow the user to embed Daedalus code within the dialogue. In effect, any line that doesn't start with certain terminals should be interpreted as code. Is there any way to do this? A really short example would look like this:

namespace test {
dialog {
<< hey there!
>> Who me?
RandomCall(); // This line is code and can be parsed as a pure string ie it will end up in the output file just like it is here
}
}

I'm not very experienced with BNF so I might overlook an extremly simple solution.


Regards, Leon

--
You received this message because you are subscribed to the Google Groups "GOLD Parsing System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gold-parsing-sy...@googlegroups.com.
To post to this group, send email to gold-pars...@googlegroups.com.
Visit this group at http://groups.google.com/group/gold-parsing-system?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
---------------------------------------------------------------
Dave Dolan
http://davedolan.com/blog

Arsène von Wyss

unread,
Feb 2, 2013, 5:05:43 PM2/2/13
to gold-pars...@googlegroups.com
Well, if basically every line start that your language doesn't recognize is to be kept "literal" and passed through to the output, you may want to not do much in the grammar except for allowing a special virtual token as line placeholder. Then hook into the LALR processor and the tokenizer; when you hit a syntax error and the token is the first non-whitespace on a line, then just read to the end of the line, create a virtual token for that text segment, and resume your processing.

You may need to look into the engine which you're using to see whether it can handle something like that. If you're using .NET, then you could consider using my BSN engine which has all the necessary hooks to make this work.

Good luck, Arsène
Reply all
Reply to author
Forward
0 new messages