How to Convert usual text to executable machine code in python

0 votes

I need to solve the task, connecting with creating of DSL. First, what should I do to translate text to machine code. For example:

text: 'If salary more than 5000 do op1'

should be translated to..

if salary > 5000:
    op1

Is any way to do it? Maybe it other langs

Oct 1, 2018 in Python by bug_seeker
• 15,390 points
748 views

1 answer to this question.

0 votes

what you are looking for is a compiler, Yacc & Flex using BISON GNU.

Yacc: Yacc wiki & BISON GNU Docs

But before going through that, you need to know about context free grammars.

Context Free Grammar

answered Oct 1, 2018 by Priyaj
• 57,530 points

Related Questions In Python

0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,540 points
14,334 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

answered Dec 3, 2018 in Python by charlie_brown
• 7,760 points
199 views
0 votes
0 answers

How to read lines from compressed text files in Python

Is it easy to read a line ...READ MORE

Dec 27, 2018 in Python by Anirudh
• 2,080 points
128 views
0 votes
1 answer

How can I write code to find a palindrome in python without using string functions?

In Logic 1, try if i<int(length/2): instead of if i<int((length/2+1)): In ...READ MORE

answered Jan 16, 2019 in Python by charlie_brown
• 7,760 points
5,790 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 756 views
0 votes
0 answers
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 57,530 points
1,466 views
0 votes
1 answer

How to convert datetime.date to UTC timestamp in Python

In Python 3 (< 3.3) From the docs ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 57,530 points
4,773 views