Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
zilf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Jira
Jira
Labels
Merge Requests
0
Merge Requests
0
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
zilf
zilf
Commits
b050094c0140
Commit
70ee2603
authored
Dec 10, 2020
by
Jesse McGrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zilf.Language.Parser: Better handling for some syntax errors, e.g. "!<>!" or "4 :".
parent
465739e1505a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
30 deletions
+38
-30
src/Zilf/Language/Parser.cs
src/Zilf/Language/Parser.cs
+38
-30
No files found.
src/Zilf/Language/Parser.cs
View file @
b050094c0140
...
...
@@ -332,44 +332,52 @@ namespace Zilf.Language
System
.
Diagnostics
.
Debug
.
Assert
(
po
.
Object
!=
null
);
if
(!
SkipWhitespace
(
chars
))
return
po
;
try
{
if
(!
SkipWhitespace
(
chars
))
return
po
;
var
c
=
chars
.
Current
;
var
c
=
chars
.
Current
;
if
(
c
!=
':'
&&
c
!=
Bang
.
Colon
)
{
chars
.
PushBack
(
c
);
return
po
;
}
if
(
c
!=
':'
&&
c
!=
Bang
.
Colon
)
{
chars
.
PushBack
(
c
);
return
po
;
}
ParserOutput
po2
;
do
{
po2
=
ParseOneNonAdecl
(
chars
,
out
_
);
// TODO: store comment somewhere? (set SourceLine if so)
}
while
(
po2
.
IsIgnorable
);
ParserOutput
po2
;
do
{
po2
=
ParseOneNonAdecl
(
chars
,
out
_
);
// TODO: store comment somewhere? (set SourceLine if so)
}
while
(
po2
.
IsIgnorable
);
switch
(
po2
.
Type
)
{
case
ParserOutputType
.
EndOfInput
:
throw
new
ExpectedButFound
(
"object after ':'"
,
"<EOF>"
);
switch
(
po2
.
Type
)
{
case
ParserOutputType
.
EndOfInput
:
throw
new
ExpectedButFound
(
"object after ':'"
,
"<EOF>"
);
case
ParserOutputType
.
Object
:
var
adecl
=
new
ZilAdecl
(
po
.
Object
,
po2
.
Object
);
return
po
.
Type
==
ParserOutputType
.
Comment
?
ParserOutput
.
FromComment
(
adecl
)
:
ParserOutput
.
FromObject
(
adecl
);
case
ParserOutputType
.
Object
:
var
adecl
=
new
ZilAdecl
(
po
.
Object
,
po2
.
Object
);
// TODO: set source line
return
po
.
Type
==
ParserOutputType
.
Comment
?
ParserOutput
.
FromComment
(
adecl
)
:
ParserOutput
.
FromObject
(
adecl
);
case
ParserOutputType
.
SyntaxError
:
return
po2
;
case
ParserOutputType
.
SyntaxError
:
return
po2
;
case
ParserOutputType
.
Terminator
:
chars
.
MoveNext
();
throw
new
ExpectedButFound
(
"object after ':'"
,
$"'
{
chars
.
Current
.
Rebang
()}
'"
);
case
ParserOutputType
.
Terminator
:
chars
.
MoveNext
();
throw
new
ExpectedButFound
(
"object after ':'"
,
$"'
{
chars
.
Current
.
Rebang
()}
'"
);
default
:
throw
new
UnhandledCaseException
(
"object after ':'"
);
default
:
throw
new
UnhandledCaseException
(
"object after ':'"
);
}
}
catch
(
ParserException
ex
)
{
sourceLine
=
new
FileSourceLine
(
site
.
CurrentFilePath
,
line
);
return
ParserOutput
.
FromException
(
ex
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment