RPLY - Unexpected token parsing source code with multiple lines of code
up vote
0
down vote
favorite
I'm experimenting with the RPLY library, which by the way looks awesome. However, my parser works fine if my source code has just one line in it. If I add another line of code the parser throws an exception. Anyone else seen this. My parser is pretty basic as the moment, and if I parse each line individually then I have no problem.
My source code looks like this:
MULTIPLY 10 BY 20 GIVING PRICE.
* This is a comment.
as I say, parsing each line separately is no problem.
Any help/pointers greatly received!!!
python-3.x parsing cobol ply
|
show 5 more comments
up vote
0
down vote
favorite
I'm experimenting with the RPLY library, which by the way looks awesome. However, my parser works fine if my source code has just one line in it. If I add another line of code the parser throws an exception. Anyone else seen this. My parser is pretty basic as the moment, and if I parse each line individually then I have no problem.
My source code looks like this:
MULTIPLY 10 BY 20 GIVING PRICE.
* This is a comment.
as I say, parsing each line separately is no problem.
Any help/pointers greatly received!!!
python-3.x parsing cobol ply
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
1
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces:Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
1
Ifprogram
is the start symbol, then any production after theMULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as themultiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.
– Rick Smith
Nov 11 at 15:01
|
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm experimenting with the RPLY library, which by the way looks awesome. However, my parser works fine if my source code has just one line in it. If I add another line of code the parser throws an exception. Anyone else seen this. My parser is pretty basic as the moment, and if I parse each line individually then I have no problem.
My source code looks like this:
MULTIPLY 10 BY 20 GIVING PRICE.
* This is a comment.
as I say, parsing each line separately is no problem.
Any help/pointers greatly received!!!
python-3.x parsing cobol ply
I'm experimenting with the RPLY library, which by the way looks awesome. However, my parser works fine if my source code has just one line in it. If I add another line of code the parser throws an exception. Anyone else seen this. My parser is pretty basic as the moment, and if I parse each line individually then I have no problem.
My source code looks like this:
MULTIPLY 10 BY 20 GIVING PRICE.
* This is a comment.
as I say, parsing each line separately is no problem.
Any help/pointers greatly received!!!
python-3.x parsing cobol ply
python-3.x parsing cobol ply
edited Nov 10 at 15:00
asked Nov 9 at 9:40
Lee Harding
12
12
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
1
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces:Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
1
Ifprogram
is the start symbol, then any production after theMULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as themultiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.
– Rick Smith
Nov 11 at 15:01
|
show 5 more comments
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
1
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces:Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
1
Ifprogram
is the start symbol, then any production after theMULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as themultiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.
– Rick Smith
Nov 11 at 15:01
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
1
1
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:
'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces: Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:
'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces: Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
1
1
If
program
is the start symbol, then any production after the MULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as the multiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.– Rick Smith
Nov 11 at 15:01
If
program
is the start symbol, then any production after the MULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as the multiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.– Rick Smith
Nov 11 at 15:01
|
show 5 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53223209%2frply-unexpected-token-parsing-source-code-with-multiple-lines-of-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You might want to add a tag to your question stating which programming language you're using to parse. For someone unfamiliar with the library you mention, the language is just not obvious.
– aaaaaa123456789
Nov 9 at 9:58
1
What token was unexpected? Are you using fixed or free format for the COBOL code?
– Rick Smith
Nov 10 at 16:01
The unexpected token is on the next line. So, given the example above, the unexpected token in a comment ("*"). My parser production looks like:
'program : MULTIPLY expression BY expression GIVING expression PERIOD
The lexer produces:Token('MULTIPLY', 'MULTIPLY') Token('INTEGER', '10') Token('BY', 'BY') Token('INTEGER', '20') Token('GIVING', 'GIVING') Token('IDENTIFIER', 'PRICE') Token('PERIOD', '.') Token('COMMENT', '* This is a comment.')
– Lee Harding
Nov 10 at 16:33
free format, forgot to mention :-)
– Lee Harding
Nov 10 at 16:54
1
If
program
is the start symbol, then any production after theMULTIPLY
statement will be an "unexpected token". You could also place the comment on the same line as themultiply
statement to see if it fails. Beyond that I think you will need to post some code for others to examine.– Rick Smith
Nov 11 at 15:01