国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Mini Java編譯器(二)——語法(BNF)

2019-11-18 14:23:51
字體:
來源:轉載
供稿:網友

  二、Mini java的文法
BNF
Goal
::=
MainClass ( TypeDeclaration )* <EOF>

MainClass
::=
"class" Identifier "{" "public" "static" "void" "main" "(" "String" "[" "]" Identifier ")" "{" PRintStatement "}" "}"

TypeDeclaration
::=
ClassDeclaration



ClassExtendsDeclaration

ClassDeclaration
::=
"class" Identifier "{" ( VarDeclaration )* ( MethodDeclaration )* "}"

ClassExtendsDeclaration
::=
"class" Identifier "extends" Identifier "{" ( VarDeclaration )* ( MethodDeclaration )* "}"

VarDeclaration
::=
Type Identifier ";"

MethodDeclaration
::=
"public" Type Identifier "(" ( FormalParameterList )? ")" "{" ( VarDeclaration )* ( Statement )* "return" EXPression ";" "}"

FormalParameterList
::=
FormalParameter ( FormalParameterRest )*

FormalParameter
::=
Type Identifier

FormalParameterRest
::=
"," FormalParameter

Type
::=
ArrayType



BooleanType



IntegerType



Identifier

ArrayType
::=
"int" "[" "]"

BooleanType
::=
"boolean"

IntegerType
::=
"int"

Statement
::=
Block



AssignmentStatement



ArrayAssignmentStatement



IfStatement



WhileStatement



PrintStatement

Block
::=
"{" ( Statement )* "}"

AssignmentStatement
::=
Identifier "=" Expression ";"

ArrayAssignmentStatement
::=
Identifier "[" Expression "]" "=" Expression ";"

IfStatement
::=
"if" "(" Expression ")" Statement "else" Statement

WhileStatement
::=
"while" "(" Expression ")" Statement

PrintStatement

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 普安县| 安顺市| 顺义区| 余庆县| 墨玉县| 蒲江县| 南郑县| 买车| 河源市| 玉溪市| 台湾省| 谢通门县| 璧山县| 蒙城县| 井研县| 通渭县| 自贡市| 宜兰县| 清丰县| 嵊泗县| 夏河县| 麟游县| 怀仁县| 浦北县| 军事| 建昌县| 凤山县| 舟曲县| 郧西县| 北京市| 贡嘎县| 株洲市| 闽清县| 阜康市| 武穴市| 昌江| 宝山区| 淳安县| 淳安县| 隆化县| 涞源县|