-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
173 lines (118 loc) · 6.37 KB
/
Copy pathindex.html
File metadata and controls
173 lines (118 loc) · 6.37 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verification" content="Wrn5zZ5tKu31IhW82sFSwPUlE9hhn3ScrumIDHCS4kw" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/Python-Lexer-and-Parser/assets/css/style.css?v=290ee773de47ca31b9651599535636fd316de3d8" media="screen" type="text/css">
<link rel="stylesheet" href="/Python-Lexer-and-Parser/assets/css/print.css" media="print" type="text/css">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Python-Lexer-and-Parser | A Lexical Analyzer and Parser Written in Python</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta property="og:title" content="Python-Lexer-and-Parser" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A Lexical Analyzer and Parser Written in Python" />
<meta property="og:description" content="A Lexical Analyzer and Parser Written in Python" />
<link rel="canonical" href="https://xerckm.github.io/Python-Lexer-and-Parser/" />
<meta property="og:url" content="https://xerckm.github.io/Python-Lexer-and-Parser/" />
<meta property="og:site_name" content="Python-Lexer-and-Parser" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Python-Lexer-and-Parser" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","description":"A Lexical Analyzer and Parser Written in Python","headline":"Python-Lexer-and-Parser","name":"Python-Lexer-and-Parser","url":"https://xerckm.github.io/Python-Lexer-and-Parser/"}</script>
<!-- End Jekyll SEO tag -->
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->
<!-- Setup Google Analytics -->
<!-- You can set your favicon here -->
<!-- link rel="shortcut icon" type="image/x-icon" href="/Python-Lexer-and-Parser/favicon.ico" -->
<!-- end custom head snippets -->
</head>
<body>
<header>
<div class="inner">
<a href="https://xerckm.github.io/Python-Lexer-and-Parser/">
<h1>Python-Lexer-and-Parser</h1>
</a>
<h2>A Lexical Analyzer and Parser Written in Python</h2>
<a href="https://github.com/XerckM/Python-Lexer-and-Parser" class="button"><small>View project on</small> GitHub</a>
</div>
</header>
<div id="content-wrapper">
<div class="inner clearfix">
<section id="main-content">
<h1 id="python-lexer-and-parser">Python-Lexer-and-Parser</h1>
<p>This is a project to create a lexer and parser using python without using libraries like ‘re’.</p>
<p>Project information is in its respective folder.</p>
<p>This project is for learning purposes only.</p>
<p>Project is written in Python 3.10 (to work with match case)</p>
<h2 id="the-syntax">The syntax</h2>
<p>Program = “program” Identifier “:” Body “end” .</p>
<p>Body = [ Declarations ] Statements .</p>
<p>Declarations = Declaration { Declaration } .</p>
<p>Declaration = ( “bool” | “int” ) Identifier “;” .</p>
<p>Statements = Statement { “;” Statement } .</p>
<p>Statement = AssignmentStatement
| ConditionalStatement
| IterativeStatement
| PrintStatement .</p>
<p>AssignmentStatement = Identifier “:=” Expression .</p>
<p>ConditionalStatement = “if” Expression
“then” Body
[ “else” Body ]
“fi” .</p>
<p>IterativeStatement = “while” Expression “do” Body “od” .</p>
<p>PrintStatement = “print” Expression .</p>
<p>Expression = SimpleExpression [ RelationalOperator SimpleExpression ] .</p>
<p>RelationalOperator = “<” | “=<” | “=” | “!=” | “>=” | “>” .</p>
<p>SimpleExpression = Term { AdditiveOperator Term } .</p>
<p>AdditiveOperator = “+” | “-“ | “or” .</p>
<p>Term = Factor { MultiplicativeOperator Factor } .</p>
<p>MultiplicativeOperator = “*” | “/” | “and” .</p>
<p>Factor = [ UnaryOperator ] ( Literal | Identifier | “(“ Expression “)” ) .</p>
<p>UnaryOperator = “-“ | “not” .</p>
<p>Literal = BooleanLiteral | IntegerLiteral .</p>
<p>BooleanLiteral = “false” | “true” .</p>
<p>IntegerLiteral = Digit { Digit } .</p>
<p>Identifier = Letter { Letter | Digit | “_” }.</p>
<p>Digit = “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9” .</p>
<p>Letter = “a” | “b” | “c” | “d” | “e” | “f” | “g” | “h” | “i” | “j” | “k”
| “l” | “m” | “n” | “o” | “p” | “q” | “u” | “r” | “s” | “t” | “u”
| “v” | “w” | “x” | “y” | “z”
| “A” | “B” | “C” | “D” | “E” | “F” | “G” | “H” | “I” | “J” | “K”
| “L” | “M” | “N” | “O” | “P” | “Q” | “U” | “R” | “S” | “T” | “U”
| “V” | “W” | “X” | “Y” | “Z” .</p>
<h2 id="comments">Comments:</h2>
<ol>
<li>
<p>Integer literals and identifiers are treated as terminal symbols.</p>
</li>
<li>
<p>White space is allowed anywhere, except within terminal symbols.</p>
</li>
<li>
<p>A comment begins with a double slash (“//”) and terminates at the end of
the line.</p>
</li>
<li>
<p>“Maximum munch” applies. For example, “if1” is an identifier, not an “if”
followed by a “1”.</p>
</li>
<li>
<p>The scope of a variable is from its declaration to the end of the nearest
enclosing body. Standard rules for hiding apply.</p>
</li>
</ol>
</section>
<aside id="sidebar">
<p class="repo-owner"><a href="https://github.com/XerckM/Python-Lexer-and-Parser">Python-Lexer-and-Parser</a> is maintained by <a href="https://github.com/XerckM">XerckM</a>.</p>
<p>This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</p>
</aside>
</div>
</div>
</body>
</html>