Skip to content

Commit 2fa15bf

Browse files
committed
Update start Pascal Parser
very alpha Version of Pascal Parser - the new things are only Comment parsing
1 parent e35e5d1 commit 2fa15bf

File tree

4 files changed

+77
-41
lines changed

4 files changed

+77
-41
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
2025-01-12 13:29:28,020: INFO: init ok: session start...
2-
2025-01-12 13:29:43,485: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
3-
2025-01-12 13:30:03,394: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
4-
2025-01-12 13:30:17,074: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
1+
2025-01-12 15:38:26,501: INFO: init ok: session start...
2+
2025-01-12 15:38:46,743: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
3+
2025-01-12 15:40:34,261: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
4+
2025-01-12 15:40:48,650: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
5+
2025-01-12 15:41:49,198: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
6+
2025-01-12 15:43:35,919: INFO: start parse: T:/a/HelpNDocTools/HelpNDocTools/src/__pycache__/examples/pascal/example1.pas
996 Bytes
Binary file not shown.

src/__pycache__/examples/pascal/example1.pas

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
;
21
{ this is a
32
block comment that can be appear on
43
multiple lines
@@ -9,7 +8,7 @@
98
*)
109
// this is a C++ Comment which is valide for modern Pascal
1110
program{comment} test {comment between symbols} ; { comment }
12-
procedure {comment} testproc (*comment*) (string:
11+
procedure {comment} testproc (*comment*) ( {comment}arg1 {ccc} :(*vvvv*) String {cccc}) {comment} ; (*cccc*)
1312
begin{comment } (*vvvv*)
1413
end (*comment*) .
1514
(*
@@ -29,4 +28,4 @@ function funa(): Boolean;
2928
begin
3029
end.
3130
*)
32-
(**)
31+
(**)

src/client.py

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4839,7 +4839,7 @@ def getIdent(self):
48394839
genv.char_prev = genv.char_curr
48404840
self.getChar()
48414841

4842-
if genv.char_curr.isalpha():
4842+
if genv.char_curr.isalnum():
48434843
self.token_str += genv.char_curr
48444844
continue
48454845
else:
@@ -5037,28 +5037,27 @@ def handle_pascal_comment_2(self):
50375037
continue
50385038
else:
50395039
continue
5040-
5041-
if genv.char_curr.isalpha():
5042-
if self.check_ident():
5043-
showInfo("argument: " + self.token_str)
5044-
while True:
5045-
genv.char_prev = genv.char_curr
5046-
self.getChar()
5040+
else:
5041+
while True:
5042+
genv.char_prev = genv.char_curr
5043+
self.getChar()
50475044

5048-
if self.check_white_spaces():
5049-
continue
5050-
elif self.check_char('{'):
5051-
self.handle_pascal_comment_1()
5052-
continue
5053-
elif self.check_char('('):
5054-
self.handle_pascal_comment_2() # todo: expr
5055-
continue
5056-
5057-
elif self.check_char(':'):
5045+
if self.check_white_spaces():
5046+
continue
5047+
elif self.check_char('{'):
5048+
self.handle_pascal_comment_1()
5049+
continue
5050+
elif self.check_char('('):
5051+
self.handle_pascal_comment_2() # todo: expr
5052+
continue
5053+
5054+
elif genv.char_curr.isalpha():
5055+
if self.check_ident():
5056+
showInfo("argument: " + self.token_str)
50585057
while True:
50595058
genv.char_prev = genv.char_curr
50605059
self.getChar()
5061-
5060+
50625061
if self.check_white_spaces():
50635062
continue
50645063
elif self.check_char('{'):
@@ -5068,9 +5067,8 @@ def handle_pascal_comment_2(self):
50685067
self.handle_pascal_comment_2() # todo: expr
50695068
continue
50705069

5071-
elif genv.char_curr.isalpha():
5072-
self.handle_pascal_argument_type()
5073-
5070+
elif self.check_char(':'):
5071+
showInfo(":::::")
50745072
while True:
50755073
genv.char_prev = genv.char_curr
50765074
self.getChar()
@@ -5083,23 +5081,60 @@ def handle_pascal_comment_2(self):
50835081
elif self.check_char('('):
50845082
self.handle_pascal_comment_2() # todo: expr
50855083
continue
5086-
5087-
elif self.check_char(')'):
5088-
showInfo("list ende.")
5089-
break
5084+
5085+
elif genv.char_curr.isalpha():
5086+
self.handle_pascal_argument_type()
5087+
5088+
while True:
5089+
genv.char_prev = genv.char_curr
5090+
self.getChar()
5091+
5092+
if self.check_white_spaces():
5093+
continue
5094+
elif self.check_char('{'):
5095+
self.handle_pascal_comment_1()
5096+
continue
5097+
elif self.check_char('('):
5098+
self.handle_pascal_comment_2() # todo: expr
5099+
continue
5100+
5101+
elif self.check_char(')'):
5102+
showInfo("list ende.")
5103+
5104+
while True:
5105+
genv.char_prev = genv.char_curr
5106+
self.getChar()
5107+
5108+
if self.check_white_spaces():
5109+
continue
5110+
elif self.check_char('{'):
5111+
self.handle_pascal_comment_1()
5112+
continue
5113+
elif self.check_char('('):
5114+
self.handle_pascal_comment_2() # todo: expr
5115+
continue
5116+
5117+
elif self.check_char(';'):
5118+
showInfo("procedure ende.")
5119+
break
5120+
else:
5121+
raise Exception(_("semicolon (;) expected."))
5122+
break
5123+
else:
5124+
raise Exception(_("argument type expected."))
5125+
break
5126+
break
50905127
else:
5091-
raise Exception(_("argument type expected."))
5128+
raise Exception(_("colon (:) expected."))
5129+
break
50925130
break
50935131
else:
5094-
raise Exception(_("colon (:) expected."))
5095-
5096-
return True
5097-
5098-
else:
5099-
raise Exception(_("Error:\nPascal comment expected."))
5132+
raise Exception(_("ident expected."))
5133+
else:
5134+
raise Exception(_("wrong char type."))
51005135

51015136
def handle_pascal_argument_type(self):
5102-
self.ungetChar(1)
5137+
#self.ungetChar(1)
51035138
self.check_ident()
51045139
showInfo("argument type: " + self.token_str)
51055140

0 commit comments

Comments
 (0)