I have a text I am trying to make a Parser, best way to do it?












-1















I have a text file:



if x < 5 then
{
BLA BLA BLA BLA BLA BLA
}
else
{
BLA BLA BLA BLA BLA
}
fi


(IF Condition) (x<5 Expresion) (Then Condition) LINE ONE CORRECT
( { BLOCK ) LINE ACCEPTED
STATEMENT1 ACCEPTED .. .. .. ..
( } BLOCK ) LINE ACCEPTED



but if the statement does not have a THEN or ELSE or FI it will all be incorrect.










share|improve this question























  • You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

    – 0xc0de
    Nov 22 '18 at 4:35











  • It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

    – David Makogon
    Nov 23 '18 at 4:05
















-1















I have a text file:



if x < 5 then
{
BLA BLA BLA BLA BLA BLA
}
else
{
BLA BLA BLA BLA BLA
}
fi


(IF Condition) (x<5 Expresion) (Then Condition) LINE ONE CORRECT
( { BLOCK ) LINE ACCEPTED
STATEMENT1 ACCEPTED .. .. .. ..
( } BLOCK ) LINE ACCEPTED



but if the statement does not have a THEN or ELSE or FI it will all be incorrect.










share|improve this question























  • You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

    – 0xc0de
    Nov 22 '18 at 4:35











  • It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

    – David Makogon
    Nov 23 '18 at 4:05














-1












-1








-1








I have a text file:



if x < 5 then
{
BLA BLA BLA BLA BLA BLA
}
else
{
BLA BLA BLA BLA BLA
}
fi


(IF Condition) (x<5 Expresion) (Then Condition) LINE ONE CORRECT
( { BLOCK ) LINE ACCEPTED
STATEMENT1 ACCEPTED .. .. .. ..
( } BLOCK ) LINE ACCEPTED



but if the statement does not have a THEN or ELSE or FI it will all be incorrect.










share|improve this question














I have a text file:



if x < 5 then
{
BLA BLA BLA BLA BLA BLA
}
else
{
BLA BLA BLA BLA BLA
}
fi


(IF Condition) (x<5 Expresion) (Then Condition) LINE ONE CORRECT
( { BLOCK ) LINE ACCEPTED
STATEMENT1 ACCEPTED .. .. .. ..
( } BLOCK ) LINE ACCEPTED



but if the statement does not have a THEN or ELSE or FI it will all be incorrect.







python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 4:04









NickNick

35




35













  • You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

    – 0xc0de
    Nov 22 '18 at 4:35











  • It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

    – David Makogon
    Nov 23 '18 at 4:05



















  • You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

    – 0xc0de
    Nov 22 '18 at 4:35











  • It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

    – David Makogon
    Nov 23 '18 at 4:05

















You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

– 0xc0de
Nov 22 '18 at 4:35





You can read about the python syntax here: docs.python.org/3/tutorial/controlflow.html#if-statements.

– 0xc0de
Nov 22 '18 at 4:35













It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

– David Makogon
Nov 23 '18 at 4:05





It's unclear what, exactly, you're asking. You're creating a parser? If so, where is your parsing code? Where are you stuck? What is expected vs actual output? As written, it's not clear, and it's also very broad (e.g. there are lots of ways to create a parser).

– David Makogon
Nov 23 '18 at 4:05












1 Answer
1






active

oldest

votes


















0














If I understand correctly, python definitely has what you are asking for.



Just look at the syntaxes at any of the python starter resource like a tutorial or even official docs.
Here is the syntax for what you are asking.



if x < 5:
# Code to be executed when condition matches.
pass # Remove this when there's actual code.
else: # You can also have elif here for non-overlapping conditions and with condition precedences.
# Code to be executed otherwise ie. when the first condition fails.
pass





share|improve this answer
























  • Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

    – David Makogon
    Nov 23 '18 at 4:03











  • @DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

    – shoonya ek
    Nov 23 '18 at 6:27











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',
autoActivateHeartbeat: false,
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%2f53423725%2fi-have-a-text-i-am-trying-to-make-a-parser-best-way-to-do-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If I understand correctly, python definitely has what you are asking for.



Just look at the syntaxes at any of the python starter resource like a tutorial or even official docs.
Here is the syntax for what you are asking.



if x < 5:
# Code to be executed when condition matches.
pass # Remove this when there's actual code.
else: # You can also have elif here for non-overlapping conditions and with condition precedences.
# Code to be executed otherwise ie. when the first condition fails.
pass





share|improve this answer
























  • Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

    – David Makogon
    Nov 23 '18 at 4:03











  • @DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

    – shoonya ek
    Nov 23 '18 at 6:27
















0














If I understand correctly, python definitely has what you are asking for.



Just look at the syntaxes at any of the python starter resource like a tutorial or even official docs.
Here is the syntax for what you are asking.



if x < 5:
# Code to be executed when condition matches.
pass # Remove this when there's actual code.
else: # You can also have elif here for non-overlapping conditions and with condition precedences.
# Code to be executed otherwise ie. when the first condition fails.
pass





share|improve this answer
























  • Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

    – David Makogon
    Nov 23 '18 at 4:03











  • @DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

    – shoonya ek
    Nov 23 '18 at 6:27














0












0








0







If I understand correctly, python definitely has what you are asking for.



Just look at the syntaxes at any of the python starter resource like a tutorial or even official docs.
Here is the syntax for what you are asking.



if x < 5:
# Code to be executed when condition matches.
pass # Remove this when there's actual code.
else: # You can also have elif here for non-overlapping conditions and with condition precedences.
# Code to be executed otherwise ie. when the first condition fails.
pass





share|improve this answer













If I understand correctly, python definitely has what you are asking for.



Just look at the syntaxes at any of the python starter resource like a tutorial or even official docs.
Here is the syntax for what you are asking.



if x < 5:
# Code to be executed when condition matches.
pass # Remove this when there's actual code.
else: # You can also have elif here for non-overlapping conditions and with condition precedences.
# Code to be executed otherwise ie. when the first condition fails.
pass






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 4:27









shoonya ekshoonya ek

215




215













  • Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

    – David Makogon
    Nov 23 '18 at 4:03











  • @DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

    – shoonya ek
    Nov 23 '18 at 6:27



















  • Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

    – David Makogon
    Nov 23 '18 at 4:03











  • @DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

    – shoonya ek
    Nov 23 '18 at 6:27

















Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

– David Makogon
Nov 23 '18 at 4:03





Please re-read the OP's question. They're not asking about an if block. They want to construct a parser that parses an if block. A question that's very broad (and off-topic).

– David Makogon
Nov 23 '18 at 4:03













@DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

– shoonya ek
Nov 23 '18 at 6:27





@DavidMakogon Well I re-read it multiple times, and this is the best I could conceive. I tried to answer that, and if/when the question is modified to be able to convey the actual problem better, I will update the answer. I don't mind your downvote :) though.

– shoonya ek
Nov 23 '18 at 6:27


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423725%2fi-have-a-text-i-am-trying-to-make-a-parser-best-way-to-do-it%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

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen