New article MQL Parsing by Means of MQL has been published:
The article describes a preprocessor, a scanner, and a parser to be used in parsing the MQL-based source codes. MQL implementation is attached.
Programming is essentially formalizing and automating some processes using general-purpose or special-purpose languages. The MetaTrader
trading platform allows applying programming to solving a wide variety
of the trader's problems, using embedded MQL language. Normally, the
coding process is based on analyzing and processing application data
according to the rules specified in source codes. However, a need
sometimes arises for analyzing and processing the source codes
themselves. Here are some examples.
One of the most consistent and popular tasks is contextual and
semantic search in source code base. Surely, you can search for strings
in a source code as in a normal text; however, the semantics of the
sought for is getting lost. After all, in case of source codes, it is
desirable to distinguish among the specifics of using the substring in
each specific case. If a programmer wants to find where a specific
variable is used, such as "notification," then a simple search by its
name can return much more than necessary, where the string occurs in
other values, such as a method name or a literal, or in comments.
A more complicated and sought for, as a rule, at larger projects, is
the task of identifying code structure, dependencies, and class
hierarchy. It is closely connected to meta-programming that allows
performing code refactoring/improving and code generation. Recall that MetaEditor provides some opportunities of generating codes, particularly, creating the source codes of Expert Advisors using Wizard or forming a header file by source code. However, the potentials of this technology are much more powerful.
Code structure analysis allows computing various quality metrics
and statistics, as well as finding the typical sources of runtime
errors that cannot be detected by the compiler. In fact, compiler itself
is, of course, the first tool of analyzing a source code and returns
warnings of many types; however, checking for all potential errors is
not usually built into it — this task is too large, so it is normally
assigned to separate programs.
Moreover, parsing source codes is used for styling (formatting) and obfuscation (scrambling).
Author: Stanislav Korotky