Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pga
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
pga
Commits
3e754a51
Commit
3e754a51
authored
10 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Better errors for unmatching parentheses
parent
23418c16
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parse.ml
+10
-3
10 additions, 3 deletions
parse.ml
with
10 additions
and
3 deletions
parse.ml
+
10
−
3
View file @
3e754a51
...
...
@@ -19,9 +19,9 @@ let tokenize next_char emit =
in
let
emit_buf
()
=
match
Buffer
.
length
buf
with
|
0
->
()
|
_
->
if
Buffer
.
length
buf
=
0
then
()
else
emit
(
ID
(
Buffer
.
contents
buf
));
Buffer
.
clear
buf
in
...
...
@@ -74,6 +74,9 @@ let parse next_char =
|
MINUS
->
expect
:=
E_ntest
|
LPAREN
->
stack
:=
ref
[]
::
!
stack
|
RPAREN
->
if
List
.
length
!
stack
<
2
then
begin
raise
(
ParseError
"too many closing parentheses"
)
end
;
let
body
=
List
.
rev
!
(
List
.
hd
!
stack
)
in
stack
:=
List
.
tl
!
stack
;
append
(
Repeat
(
program_of_list
body
))
...
...
@@ -89,6 +92,10 @@ let parse next_char =
expect
:=
E_basic
in
tokenize
next_char
handler
;
if
List
.
length
!
stack
>
1
then
raise
(
ParseError
"missing closing parenthesis"
);
Concat
(
List
.
rev
!
(
List
.
hd
!
stack
))
let
parse_string
s
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment