Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am currently writing a grammar for a programming language (PowerBuilder) and I am also collecting documentation about parsing and compilers creation.

Now I would like to add in my grammar (that looks roughly like Visual Basic) the possibility to handle embedded SQL statements that are supported inline by the language (with the usage of binding variables like select foo into :ls_bar from baz where col=:ls_criteria;). As the embedded SQL is regular SQL syntax, I would not complexify my existing grammar but instead adapt an existing SQL-92 grammar to my needs and use it on these SQL blocks.

The parser generator that I am mainly using (AntLR) has some possibilities to support mixed or "island" grammars as described in that article or another.

I would like to compare these techniques with AntLR with others tools like Lex/Yacc, Flex, JFlex, that I used while playing with several simple language designs described in different CS courses available online.

Could you point me to examples of implementations of parsers that support mixed grammars?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

PEGs and all the other lexerless approaches allow to mix any kind of grammars. See Katahdin for an inspiration.

share|improve this answer
    
Linked from the Katahdin page, there is The Packrat Parsing and Parsing Expression Grammars Page that is very interesting. Thanks. –  Seki Jul 19 '12 at 11:54
    
@Seki, you may also find this example interesting: bit.ly/vqqvHU –  SK-logic Jul 19 '12 at 12:09
    
it is interesting indeed. BTW you should not have used an url shortener: the actual url PFront: a language with extensible syntax is better to know what it is about. –  Seki Aug 7 '12 at 10:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.