76 lines
2.4 KiB
HTML
76 lines
2.4 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta charset="utf-8">
|
|||
|
<title>Assignment</title>
|
|||
|
<link rel="stylesheet" href="lib/bootstrap.min.css">
|
|||
|
<link rel="stylesheet" href="lib/codemirror.min.css">
|
|||
|
<link rel="stylesheet" href="main.css">
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div id="root" class="container">
|
|||
|
<h1>Lexical, Syntax & Semantic Analysis</h1>
|
|||
|
<dl class="row mt-5">
|
|||
|
<dt class="col-sm-2">Requirements: </dt>
|
|||
|
<dd class="col-sm-10">
|
|||
|
<pre>
|
|||
|
# 保留字或運算子:begin, for, end, if, then, else, while, int
|
|||
|
# 運算子:+, -, *, /, =
|
|||
|
# 判斷子:<, >, <=, >=, ==, and, or
|
|||
|
# 若有詞法或語法錯誤,請印出並說明
|
|||
|
# 請印出所有變數最後的狀態
|
|||
|
# 自定義文法,使得以下範例成立:
|
|||
|
|
|||
|
begin
|
|||
|
int x=0, zzz=5;
|
|||
|
int i, j=1;
|
|||
|
# 進行迴圈
|
|||
|
for, i=1, i<=50, j; # j爲i每次遞增的值
|
|||
|
x=x+1;
|
|||
|
end
|
|||
|
if ((x>5) and (j<=8)) then
|
|||
|
x=1;
|
|||
|
else
|
|||
|
for, i=1, i<=50, j+1;
|
|||
|
x=x+1;
|
|||
|
end
|
|||
|
while (i<11)
|
|||
|
yy=x;
|
|||
|
i=i+1;
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
</pre>
|
|||
|
</dd>
|
|||
|
<dt class="col-sm-2">Source Code: </dt>
|
|||
|
<dd class="col-sm-10">
|
|||
|
<div class="custom-file">
|
|||
|
<input type="file" id="file" class="custom-file-input" @change="fileHandler">
|
|||
|
<label class="custom-file-label" for="file">{{ file ? file.name : 'Choose file' }}</label>
|
|||
|
<button type="button" class="btn btn-secondary" @click="fileHandler">Reload</button>
|
|||
|
</div>
|
|||
|
<div id="editor" class="editor"></div>
|
|||
|
</dd>
|
|||
|
<dt class="col-sm-2"></dt>
|
|||
|
<dd class="col-sm-10">
|
|||
|
<button type="button" class="btn btn-info" @click="lexer">Lex</button>
|
|||
|
<button type="button" class="btn btn-info" @click="parser">Parse</button>
|
|||
|
<button type="button" class="btn btn-primary" @click="run">Run</button>
|
|||
|
<button type="button" class="btn btn-secondary" @click="reset">Clear</button>
|
|||
|
</dd>
|
|||
|
<hr>
|
|||
|
<dt class="col-sm-2">Console: </dt>
|
|||
|
<dd class="col-sm-10">
|
|||
|
<pre class="error" v-if="error" v-text="error"></pre>
|
|||
|
<pre v-if="!error && ids.length" v-for="(v, i) in ids">{{ v }}: {{ vars[i] }}</pre>
|
|||
|
<p v-if="!error && lex.length" v-for="(l, i) in lex">{{ l }}</p>
|
|||
|
<pre v-if="!error && json" v-text="json"></pre>
|
|||
|
</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<script src="lib/codemirror.min.js"></script>
|
|||
|
<script src="lib/vue-2.6.0.min.js"></script>
|
|||
|
<script src="main.js"></script>
|
|||
|
</body>
|
|||
|
</html>
|