Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
434ed1ed
Commit
434ed1ed
authored
May 17, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile error should contain line number
parent
0bae9c50
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
+22
-21
src/compile.h
src/compile.h
+2
-2
src/parse.y
src/parse.y
+18
-17
tools/mrbc/mrbc.c
tools/mrbc/mrbc.c
+1
-1
tools/mruby/mruby.c
tools/mruby/mruby.c
+1
-1
No files found.
src/compile.h
View file @
434ed1ed
...
@@ -77,13 +77,13 @@ struct mrb_parser_state {
...
@@ -77,13 +77,13 @@ struct mrb_parser_state {
jmp_buf
jmp
;
jmp_buf
jmp
;
};
};
struct
mrb_parser_state
*
mrb_parse_file
(
mrb_state
*
,
FILE
*
);
struct
mrb_parser_state
*
mrb_parse_file
(
mrb_state
*
,
FILE
*
,
const
char
*
,
int
);
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
);
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
);
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
size_t
);
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
size_t
);
struct
mrb_parser_state
*
mrb_parse_nstring_ext
(
mrb_state
*
,
const
char
*
,
size_t
);
struct
mrb_parser_state
*
mrb_parse_nstring_ext
(
mrb_state
*
,
const
char
*
,
size_t
);
int
mrb_generate_code
(
mrb_state
*
,
mrb_ast_node
*
);
int
mrb_generate_code
(
mrb_state
*
,
mrb_ast_node
*
);
int
mrb_compile_file
(
mrb_state
*
,
FILE
*
);
int
mrb_compile_file
(
mrb_state
*
,
FILE
*
,
const
char
*
,
int
);
int
mrb_compile_string
(
mrb_state
*
,
char
*
);
int
mrb_compile_string
(
mrb_state
*
,
char
*
);
int
mrb_compile_nstring
(
mrb_state
*
,
char
*
,
size_t
);
int
mrb_compile_nstring
(
mrb_state
*
,
char
*
,
size_t
);
...
...
src/parse.y
View file @
434ed1ed
...
@@ -2915,10 +2915,10 @@ yyerror(parser_state *p, const char *s)
...
@@ -2915,10 +2915,10 @@ yyerror(parser_state *p, const char *s)
if (! p->capture_errors) {
if (! p->capture_errors) {
if (p->filename) {
if (p->filename) {
fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column, s);
fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column
+1
, s);
}
}
else {
else {
fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column, s);
fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column
+1
, s);
}
}
}
}
else if (p->nerr < sizeof(p->error_buffer) / sizeof(p->error_buffer[0])) {
else if (p->nerr < sizeof(p->error_buffer) / sizeof(p->error_buffer[0])) {
...
@@ -2927,7 +2927,7 @@ yyerror(parser_state *p, const char *s)
...
@@ -2927,7 +2927,7 @@ yyerror(parser_state *p, const char *s)
memcpy(c, s, n + 1);
memcpy(c, s, n + 1);
p->error_buffer[p->nerr].message = c;
p->error_buffer[p->nerr].message = c;
p->error_buffer[p->nerr].lineno = p->lineno;
p->error_buffer[p->nerr].lineno = p->lineno;
p->error_buffer[p->nerr].column = p->column;
p->error_buffer[p->nerr].column = p->column
+1
;
}
}
p->nerr++;
p->nerr++;
}
}
...
@@ -3020,19 +3020,10 @@ nextc(parser_state *p)
...
@@ -3020,19 +3020,10 @@ nextc(parser_state *p)
c = *p->s++;
c = *p->s++;
}
}
if (c == '\n') {
if (c == '\n') {
if (p->column < 0) {
p->column++; // pushback caused an underflow
}
else {
p->lineno++;
p->column = 0;
}
// must understand heredoc
// must understand heredoc
}
}
else {
p->column++;
p->column++;
}
}
}
return c;
return c;
}
}
...
@@ -3395,6 +3386,8 @@ parse_qstring(parser_state *p, int term)
...
@@ -3395,6 +3386,8 @@ parse_qstring(parser_state *p, int term)
c = nextc(p);
c = nextc(p);
switch (c) {
switch (c) {
case '\n':
case '\n':
p->lineno++;
p->column = 0;
continue;
continue;
case '\\':
case '\\':
...
@@ -3462,6 +3455,8 @@ parser_yylex(parser_state *p)
...
@@ -3462,6 +3455,8 @@ parser_yylex(parser_state *p)
skip(p, '\n');
skip(p, '\n');
/* fall through */
/* fall through */
case '\n':
case '\n':
p->lineno++;
p->column = 0;
switch (p->lstate) {
switch (p->lstate) {
case EXPR_BEG:
case EXPR_BEG:
case EXPR_FNAME:
case EXPR_FNAME:
...
@@ -4249,6 +4244,8 @@ parser_yylex(parser_state *p)
...
@@ -4249,6 +4244,8 @@ parser_yylex(parser_state *p)
case '\\':
case '\\':
c = nextc(p);
c = nextc(p);
if (c == '\n') {
if (c == '\n') {
p->lineno++;
p->column = 0;
space_seen = 1;
space_seen = 1;
goto retry; /* skip \\n */
goto retry; /* skip \\n */
}
}
...
@@ -4678,7 +4675,7 @@ parser_new(mrb_state *mrb)
...
@@ -4678,7 +4675,7 @@ parser_new(mrb_state *mrb)
}
}
parser_state*
parser_state*
mrb_parse_file(mrb_state *mrb, FILE *f)
mrb_parse_file(mrb_state *mrb, FILE *f
, const char *fn, int line
)
{
{
parser_state *p;
parser_state *p;
...
@@ -4686,6 +4683,8 @@ mrb_parse_file(mrb_state *mrb, FILE *f)
...
@@ -4686,6 +4683,8 @@ mrb_parse_file(mrb_state *mrb, FILE *f)
if (!p) return 0;
if (!p) return 0;
p->s = p->send = NULL;
p->s = p->send = NULL;
p->f = f;
p->f = f;
if (line) p->lineno = line;
if (fn) mrb_parser_filename(p, fn);
start_parser(p);
start_parser(p);
return p;
return p;
...
@@ -4733,12 +4732,12 @@ mrb_parse_string(mrb_state *mrb, const char *s)
...
@@ -4733,12 +4732,12 @@ mrb_parse_string(mrb_state *mrb, const char *s)
void parser_dump(mrb_state *mrb, node *tree, int offset);
void parser_dump(mrb_state *mrb, node *tree, int offset);
int
int
mrb_compile_file(mrb_state * mrb, FILE *f)
mrb_compile_file(mrb_state * mrb, FILE *f
,const char *fn, int line
)
{
{
parser_state *p;
parser_state *p;
int n;
int n;
p = mrb_parse_file(mrb, f);
p = mrb_parse_file(mrb, f
, fn, line
);
if (!p) return -1;
if (!p) return -1;
if (!p->tree) return -1;
if (!p->tree) return -1;
if (p->nerr) return -1;
if (p->nerr) return -1;
...
@@ -4766,7 +4765,9 @@ mrb_parser_lineno(struct mrb_parser_state *p, int n)
...
@@ -4766,7 +4765,9 @@ mrb_parser_lineno(struct mrb_parser_state *p, int n)
if (n <= 0) {
if (n <= 0) {
return p->lineno;
return p->lineno;
}
}
return p->lineno = n;
p->column = 0;
p->lineno = n;
return n;
}
}
int
int
...
...
tools/mrbc/mrbc.c
View file @
434ed1ed
...
@@ -164,7 +164,7 @@ main(int argc, char **argv)
...
@@ -164,7 +164,7 @@ main(int argc, char **argv)
return
n
;
return
n
;
}
}
p
=
mrb_parse_file
(
mrb
,
args
.
rfp
);
p
=
mrb_parse_file
(
mrb
,
args
.
rfp
,
0
,
0
);
if
(
!
p
||
!
p
->
tree
||
p
->
nerr
)
{
if
(
!
p
||
!
p
->
tree
||
p
->
nerr
)
{
cleanup
(
&
args
);
cleanup
(
&
args
);
return
-
1
;
return
-
1
;
...
...
tools/mruby/mruby.c
View file @
434ed1ed
...
@@ -151,7 +151,7 @@ main(int argc, char **argv)
...
@@ -151,7 +151,7 @@ main(int argc, char **argv)
p
=
mrb_parse_string
(
mrb
,
(
char
*
)
args
.
cmdline
);
p
=
mrb_parse_string
(
mrb
,
(
char
*
)
args
.
cmdline
);
}
}
else
{
else
{
p
=
mrb_parse_file
(
mrb
,
args
.
rfp
);
p
=
mrb_parse_file
(
mrb
,
args
.
rfp
,
argv
[
1
],
0
);
}
}
if
(
!
p
||
!
p
->
tree
||
p
->
nerr
)
{
if
(
!
p
||
!
p
->
tree
||
p
->
nerr
)
{
cleanup
(
mrb
,
&
args
);
cleanup
(
mrb
,
&
args
);
...
...
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