“Javascript, The Good Parts”: Railroad Diagrams

后端 未结 3 1727
攒了一身酷
攒了一身酷 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:47

    I am also reading this book. It takes me a long time, but finally understand Railroad Diagrams.

    First, as @ChuckCottrill mentioned, you should have a basic acknowledge about Syntax Diagrams and BNF/EBNF. But after reading that, it still confused me until I compare three graphs of different situation:

    zero or more, zero or one, one or more

    To understand their differences (as the following picture shows), the point is "You start on the left edge and follow the tracks to the right edge." So imagine you are the train, you just turn right, cannot turn left.

    the above picture created by http://bottlecaps.de/rr/ In the "Edit Grammar" tab, input the following grammar:

    zeroormore ::= element*
    zeroorone ::= element?
    oneormore ::= element+
    

提交回复
热议问题