GNOME Bugzilla – Bug 707372
Missing lines in Language Definition Tutorial
Last modified: 2013-09-13 11:35:02 UTC
In the documentation "Language Definition v2.0 Tutorial", the full c.lang file is shown at the end of the tutorial. However, that file is missing multiple lines, and is not even valid XML. For example, the second line misses ">" at the end, the third line should be "<metadata>" and is completely missing, and so on. It seems something went wrong when the file was converted to XML and added to the tutorial. If the origional c.lang file is not available anymore, I'll help to piece together that file from the tutorial and then it should be easy to convert it to XML. Thanks, Ming
The full c.lang file from the tutorial seems outdated. I think there is no standalone version, it is only available in docs/reference/lang-tutorial.xml. The real c.lang in data/language-specs/ is much more longer.
(In reply to comment #1) > The full c.lang file from the tutorial seems outdated. I think there is no > standalone version, it is only available in docs/reference/lang-tutorial.xml. > The real c.lang in data/language-specs/ is much more longer. It's not exactly "outdated". The point of the tutorial is not to write a fully featured language definition file for C, but to use C as an example to showcase the ways to define syntax components (single line comment -- //, multi-line comment -- /* */, preprocessor macro -- #, etc.). Maybe calling it c.lang was not the best idea, let's call it c-example.lang instead. Anyway, this file can be fully constructed from the instructions and code snippets in the tutorial, the current one is just missing some lines (and half-lines). It's probably still valid XML though (contrary to what I said in the original report).
Yes, what I meant by outdated is that the full c-example.lang at the bottom was not updated when modifying other parts of the tutorial.
Created attachment 254148 [details] Updated c-example.lang spec file according to the tutorial (In reply to comment #3) > Yes, what I meant by outdated is that the full c-example.lang at the bottom was > not updated when modifying other parts of the tutorial. I understand now. Apparently the format of the language-spec file changed so much that I mistook an old version of c-example.lang as one with missing lines. Attached is the updated version of c-example.lang that I constructed from the instructions and code snippets from the tutorial. It passes the check-language.sh validation and works at a glance here (I didn't check all the implemented features though). Would you please convert it to XML format and replace the outdated one in the tutorial? Meanwhile I also found bugs in the tutorial which I'll file as a seperate report. Thanks, Ming
(In reply to comment #4) > Meanwhile I also found bugs in the tutorial which I'll file as a seperate > report. Files as #707531.
The indentation should be 2 spaces. You forgot one of the fix of bug #707531. It would be nice to have a patch (created with git format-patch) for the file in docs/reference/lang-tutorial.xml, so we can see directly the differences.
(In reply to comment #6) > The indentation should be 2 spaces. > You forgot one of the fix of bug #707531. > > It would be nice to have a patch (created with git format-patch) for the file > in docs/reference/lang-tutorial.xml, so we can see directly the differences. I didn't forgot one of the fixes, it's just my file was in XML format, not verbatim quoted format, so the "<" characters are not converted to "<" yet. I'll prepare a 2-space indentation file (note the old file in the current tutorial is 4-space, which I followed) with git format-patch in a few days.
Created attachment 254833 [details] [review] Update the language definitional file to match the tutorial text Here is the patch generated by "git format-patch". See the git commit comment for details.
Created attachment 254834 [details] [review] Update the language definitional file to match the tutorial text This is an updated patch with an extra comment for a change I forgot to comment on last time.
Review of attachment 254834 [details] [review]: Thank you very much, I've pushed the commit.