Flex & Bison: html templates
Hello folks,
I'm trying to develop an html template parser employing Flex & Bison, but now I found a problem and I don't know if surrender, so let's see if you can guide me to the solution (if any). My idea is, having an html template like: Quote:
Quote:
I have a flex file, which I show its core, mytemplate.l: Quote:
Now my problem is that I would like to get the unknown characters as an unique string. [using the flex file above, returns char by char all HTML code that is not a comment!]. So, Could it be possible to make a flex rule that gets the HTML code?. It is not necessary to check if HTML code is correct I do it (before parse) using expat. Also there is no need to check the resulted code it will be done by the parser or compiler of the used language. I know that are a lot of tools that uses this kind of templates in all languages and systems... but I'm just exercising my pour flex&bison skills. Also, using my current flex file, I have to remove the string "<!--MARKUP" from the beginning and "-->" from the end of returned string to bison... But in reality, if I could manage the HTML code as a flex rule, I could solve that sednding to bison an start Token, the code and and end token. Any hint or link will be appreciated. Thanks for reading. |
It's me again,
I have solved my problem, I don't know if it is an optimal solution but it seems to work (at least the flex's part; tomorrow I will work on bison's part). I present the full flex file (if someone wants to test and so), template.l: Quote:
It's important to note that using that code, all templates are forced to finish with an (empty) HTML coment, if not content after the last "-->" will be not processed. I close this thread as solved :) Thanks for your attention and sorry for the inconvenience (if any). |
All times are GMT -5. The time now is 08:50 AM. |