-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar_new.cs
114 lines (78 loc) · 4.17 KB
/
grammar_new.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// --------------------------------------Программа ---------------------------------------//
// Program = Elements
// Elements = { Element }
// Element = Statement
// | FunctionDeclaration
// FunctionDeclaration = function Identifier "(" [FormalParameters] ")" "{" FunctionBody "}"
// FormalParameters = Identifier [ , FormalParameters ]
// FunctionBody = Elements
// --------------------------------------Инструкции ---------------------------------------//
// Statement = Block
// | VariableStatement
// | EmptyStatement
// | ExpressionStatement
// | IfStatement
// | IterationStatement
// | BreakStatement
// | ReturnStatement |
// | SwitchStatement
// Block = "{" Statements "}"
// Statements = { Statement }
// VariableStatement = var VariableDeclarations ";"
// VariableDeclarations = VariableDeclaration { "," VariableDeclaration }
// VariableDeclaration = Identifier [ Initialiser ]
// Initialiser = "=" AssignmentExpression
// EmptyStatement = ;
// ExpressionStatement = (не начинается с {, function ) Expression ;
// IfStatement = if "(" Expression ")" Statement [ else Statement ]
// IterationStatement = do Statement while "(" Expression ")" ";"
// | while "(" Expression ")" Statement
// | for "(" ( var VariableDeclarations | [Expression]) ";" [Expression] ";" [Expression] ) Statement
// ContinueStatement = continue ";"
// BreakStatement = break ";"
// ReturnStatement = return ";"
// SwitchStatement = switch "(" Expression ")" CaseBlock
// CaseBlock = "{" [CaseClauses] [ DefaultClause [CaseClauses] ] "}"
// CaseClauses = CaseClause { CaseClause }
// CaseClause = case Expression ":" Statements
// DefaultClause = default ":" [Statements]
// --------------------------------------Выражения ---------------------------------------//
// PrimaryExpression = this
// | Identifier
// | Literal
// | ObjectLiteral
// | "(" Expression ")"
// Literal = NullLiteral
// | BooleanLiteral
// | StringLiteral
// | Number
// ObjectLiteral = "{" [PropertyNamesAndValues] "}"
// PropertyNamesAndValues = { PropertyNamesAndValues "," } PropertyAssignment
// PropertyAssignment = PropertyName ":" AssignmentExpression | get PropertyName "(" ")" "{" FunctionBody "}" |
// PropertyName = IdentifierName | StringLiteral
// MemberExpression = PrimaryExpression [ ( "." MemberExpression | "[" Expression "]" | "(" [ArgumentList] ")") ]
// ArgumentList = AssignmentExpression [ "," ArgumentList ]
// ConstructorCallExpression = Identifier [ ( "(" [ArgumentList] ")" | "." ConstructorCallExpression ) ]
// ConstructorExpression = this "." ConstructorCallExpression
// | ConstructorCallExpression
// ConstructorExpression = [this "."] ConstructorCallExpression
// UnaryExpression = MemberExpression [( "++" | "--" )]
// | ( "+" | "-" ) UnaryExpression
// | ( "++" | "--" ) MemberExpression
// | new ConstructorExpression
// | delete MemberExpression
// MultiplicativeExpression = UnaryExpression [ ( "*" | "/" | "%" ) MultiplicativeExpression ]
// AdditiveExpression = MultiplicativeExpression [ ( "+" | "-" ) AdditiveExpression ]
// ShiftExpression = AdditiveExpression [ ( "<<" | ">>" ) ShiftExpression ]
// RelationalExpression = ShiftExpression [ ( "<" | ">" | "<=" | ">=" ) RelationalExpression ]
//// RelationalExpression = ShiftExpression RelationalExpression'
//// RelationalExpression' = ( "<" | ">" | "<=" | ">=" ) ShiftExpression [ RelationalExpression' ]
// EqualityExpression = RelationalExpression [ ( "==" | "!=" ) EqualityExpression ]
// BitwiseAndExpression = EqualityExpression [ "&" BitwiseAndExpression ]
// BitwiseXorExpression = BitwiseAndExpression [ "^" BitwiseXorExpression ]
// BitwiseOrExpression = BitwiseXorExpression [ "|" BitwiseOrExpression ]
// LogicalAndExpression = BitwiseOrExpression [ "&&" LogicalAndExpression ]
// LogicalOrExpression = LogicalAndExpression [ "||" LogicalOrExpression ]
// ConditionalExpression = LogicalOrExpression [ "?" AssignmentExpression ":" AssignmentExpression ]
// AssignmentExpression = ConditionalExpression [ "=" AssignmentExpression ]
// Expression = AssignmentExpression [ "," Expression ]