Skip to content
wukunru edited this page Jun 14, 2022 · 4 revisions

高階語言

生成規則

語法理論

詞彙理論:Regular Expression(RE)

語句層次:Context-Free Grammar(CFG)

BNF

語法:

ccc4 英文語法:

ccc5

BNF和EBNF的區別

BNF
<expr> ::= <expr> + <term>
        |  <expr> - <term>
        |  <term>
<term> ::= <term> * <factor>
        |  <term> / <factor>
        |  <factor>

EBNF
<expr> ::= <term> {(+|-)<term>}
<term> ::= <factor> {(*|/) <factor>}
BNF
<signed int> ::= + <int> | - <int>
<int> ::= <digit> | <int> <digit>

EBNF
<signed int> ::= [+|-] <digit> {<digit>}*
Clone this wiki locally