Figure: mathematical expression tree node
词汇:我们用的语言可包括证书、加号和减号
语法:
<html>
<body>
<p>
Hello!
</p>
<div>
<img src="example.png"/>
</div>
</body>
</html>
<html>
<body>
Hello world!
</body>
</html>
comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/
num [0-9]+|[0-9]*"."[0-9]+
nonascii [\200-\377]
nmstart [_a-z]|{nonascii}|{escape}
nmchar [_a-z0-9-]|{nonascii}|{escape}
name {nmchar}+
ident {nmstart}{nmchar}*
<symbol> ::= __expression__
example: FOR_STATEMENT ::= "for" "(" ( variable_declaration | ( expression ";" ) | ";" ) [ expression ] ";" [ expression ] ";" ")" statement
1. 在双引号中的字("word")代表着这些字符本身2.double_quote用来代表双引号
3.在双引号外的字代表着语法部分
4.尖括号( < > )内包含为必选项。
5.方括号( [ ] )内包含为可选项
6.大括号( { } )内包含为可重复0至无数次的项
7.竖线( | )表示在其左右两边任选一项,相当于"OR"
8.::= 是“被定义为”
ruleset : selector [ ',' S* selector ]* '{' S* declaration [ ';' S* declaration ]* '}' S* ; selector : simple_selector [ combinator selector | S+ [ combinator? selector ]? ]? ;
simple_selector : element_name [ HASH | class | attrib | pseudo ]* | [ HASH | class | attrib | pseudo ]+ ; class : '.' IDENT ; element_name : IDENT | '*' ; attrib : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ] ']' ; pseudo : ':' [ IDENT | FUNCTION S* [IDENT S*] ')' ] ;
div.error , a.error {
color:red;
font-weight:bold;
}
ruleset
: selector [ ',' S* selector ]*
'{' S* declaration [ ';' S* declaration ]* '}' S* ;
## S表示空格