Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process of scanning, parsing and compiling ABAP sources?

This is a rather technical question about the compilation process of ABAP code.

I know that there are ABAP parser and scanner classes that actually call C kernel functions to do the real work. Then there is code completion functionality with a transaction that returns and prints the AST (abstract source tree) of a program as ABAP list or XML.

Now my question is: would it be possible to 'skip' the ABAP source code and directly produce such an AST by other means than writing and then executing an ABAP program in SE80 or so, and give it to some function that compiles and executes it as if it had been written in and parsed from ABAP code?

That is, can I skip scanning and parsing of sources and directly give an AST to the compiler? If so, in what format? ABAP lists look more a printing format, not like e.g. Lisp lists surrounded by parentheses.

like image 332
Thorsten Avatar asked Jan 01 '16 20:01

Thorsten


1 Answers

Unfortunately, the ABAP Compiler does not use ASTs to generate the VM code. The ABAP compiler works sequentially and translates statement per statement (i.e. everything that is between two ".") into one or more virtual machine opcodes.

If you are curious, you could take a look at transaction SYNT which shows the compiler output. You could also take a look at report RSLOAD00 which shows the ABAP VM code that has been generated for a program.

ASTs have only been built on top to allow for code completion or high-level analyses.

If you want to invoke the ABAP compiler, you will need to generate textual ABAP source code.

like image 51
user2533135 Avatar answered Nov 15 '22 11:11

user2533135