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!!!










share|improve this question
























  • 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 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















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!!!










share|improve this question
























  • 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 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













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!!!










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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




    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


















  • 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 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation