“Javascript, The Good Parts”: Railroad Diagrams

后端 未结 3 1675
攒了一身酷
攒了一身酷 2020-12-31 03:54

I\'m reading \"Javascript, The Good Parts\" by Douglas Crockford, and having a difficulty understanding the use of all the railroad diagrams. He also doesn\'t elaborate much

3条回答
  •  伪装坚强ぢ
    2020-12-31 04:38

    Railroad diagrams (Syntax diagrams, http://en.wikipedia.org/wiki/Syntax_diagram) are a graphical way to explain a grammar. If all you want to do is understand a railroad diagram, understand that you start at the left, and follow the line (track). And when you encounter a symbol/name, you go follow that track, until it is done, and then come back where you left off.

    Also, reading about BNF and EBNF (Extended? Backus-Naur Formalism, http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form) which is a formal way of describing a language grammar, using a set of productions, or rewrite rules. BNF/EBNF work the same as railroad diagrams, but using symbolic notation, the ::= production symbol, and a more formal/mathematical way to document a grammar.

提交回复
热议问题