Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pga
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pga
Commits
3e754a51
Commit
3e754a51
authored
Jul 02, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better errors for unmatching parentheses
parent
23418c16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
parse.ml
parse.ml
+10
-3
No files found.
parse.ml
View file @
3e754a51
...
@@ -19,9 +19,9 @@ let tokenize next_char emit =
...
@@ -19,9 +19,9 @@ let tokenize next_char emit =
in
in
let
emit_buf
()
=
let
emit_buf
()
=
match
Buffer
.
length
buf
with
if
Buffer
.
length
buf
=
0
then
|
0
->
()
()
|
_
->
else
emit
(
ID
(
Buffer
.
contents
buf
));
emit
(
ID
(
Buffer
.
contents
buf
));
Buffer
.
clear
buf
Buffer
.
clear
buf
in
in
...
@@ -74,6 +74,9 @@ let parse next_char =
...
@@ -74,6 +74,9 @@ let parse next_char =
|
MINUS
->
expect
:=
E_ntest
|
MINUS
->
expect
:=
E_ntest
|
LPAREN
->
stack
:=
ref
[]
::
!
stack
|
LPAREN
->
stack
:=
ref
[]
::
!
stack
|
RPAREN
->
|
RPAREN
->
if
List
.
length
!
stack
<
2
then
begin
raise
(
ParseError
"too many closing parentheses"
)
end
;
let
body
=
List
.
rev
!
(
List
.
hd
!
stack
)
in
let
body
=
List
.
rev
!
(
List
.
hd
!
stack
)
in
stack
:=
List
.
tl
!
stack
;
stack
:=
List
.
tl
!
stack
;
append
(
Repeat
(
program_of_list
body
))
append
(
Repeat
(
program_of_list
body
))
...
@@ -89,6 +92,10 @@ let parse next_char =
...
@@ -89,6 +92,10 @@ let parse next_char =
expect
:=
E_basic
expect
:=
E_basic
in
in
tokenize
next_char
handler
;
tokenize
next_char
handler
;
if
List
.
length
!
stack
>
1
then
raise
(
ParseError
"missing closing parenthesis"
);
Concat
(
List
.
rev
!
(
List
.
hd
!
stack
))
Concat
(
List
.
rev
!
(
List
.
hd
!
stack
))
let
parse_string
s
=
let
parse_string
s
=
...
...
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