On the side since last year i’ve been writing an interpreter for HTML. I don’t think HTML is a very nice language, and thought I might create an interpreter that translates my nice looking code into HTML for use on the web.
It works really well, and am using it on a little web app, but I’m having a problem parsing a particular line, and would appreciate any advice on how I could go about parsing it.
My code:
HmtlDocument {
Page.Title: "Test webpage using JTHtml";
Using[] {
"../Assets/Stylesheets/default.css",
"../Assets/Scripts/slidercordian",
"../Assets/Scripts/jquery.1.4.1.js"
};
HtmlBody {
HtmlElement Divider(container) {
HtmlElement Divider(Header) {
HtmlElement Image(Logo, "../Assets/Images/logo.png");
HtmlElement Menu(MainMenu, Horizontal, Ul, li) {
li.Text: "Home", "index.html";
li.Text: "About Us", "about.html";
li.Text: "Services", "services.html";
li.Text: "Contact Us", "contact.html";
li.Text: "My Account", "../myaccount/default.html";
}
}
HtmlElement Divider(MainContent) {
HtmlElement Heading(Heading, 1) {
Heading.Text: "Welcome!";
}
HtmlElement Text(Text) {
Text.Text: "Welcome to my new website written purely in jthtml";
}
}
}
}
See, the problem I am having is with the following line:
li.Text: "[value]", [resource]";
The old way I had it was to write it like this:
li.Text("[value]", "[resource]");
However, that doesn’t quite stay true to the rest of the syntax, which is why I would like to keep it like this:
li.Text: "[value]", "[resource]";
But I’m just not sure how I would parse that line. I’m getting stuck because of the first closing quote and the following comma, space and second opening quote. I can’t seem to figure out the right logic for it.
Any help at all is appreciated.
Thank you!
The line: li.Text: “[value]”, [resource]”; is missing an opening quote.
Are you missing an opening quote or is the parser suppose to understand it without the opening quote?