[Skip Navigation] [Remove Frame] [CS320] [Text Version] hints.syntax.html Sat Dec 23 08:00:01 PST 2006

Contents


    Hints on Writing Syntax (like in the CS320 project)

      1. Read, copy, and think about the sample syntax descriptions that are on the WWW.

      2. Go back to chapter 3. It is theoretical -- but there is nothing quite so reusable as a good theory.

      3. Write rough syntax top-down and then improve it bottom up. 4. Use good names for syntactic units. If you can't think of a descriptive name then perhaps something is wrong! 5. Start by writing examples of things in the language. Then use them to test your rules. Include the examples as comments in your grammar..

      6. Write your syntax first and then check it for ambiguity afterwards. See Chapter 3. Ambiguous syntax reduces people's belief in your abilities. It makes implementation impossible.

      7. Present your work to others. Ask for improvements. Listen to their criticism. Improve your documentation.

      8. Write syntax as if you where explaining the language to a mathematical but naive child.

      9. Practice Makes Perfect Use the XBNF notation to define

      10. Don't over define... syntax shows structure and only hints at the semantics.

      To review syntax description: write your own XBNF for some construct you know well and compare it with the versions in the languages reference manual and on the WWW.

End