Top Banner
FPVS Free Pascal Visual Studio Integration Author: Václav Čamra | Supervisor: Mgr. Pavel Ježek, Ph. D. | 2017 Introduction Architecture Pascal programming using modern IDE The Pascal programming language was designed and is still used to this day to teach procedural imperative programming. However, there are no modern high quality integrated development environments (IDEs) that could be used by students to write in the Pascal programming language. The major goal of this thesis was to fix this problem by creating a Visual Studio 2015 extension which would integrate Free Pascal programming language into Visual Studio IDE. Goals The goal of this thesis was to create a Visual Studio extension which would allow students to: 1. Compile Free Pascal programs. Only single file programs (i.e. no units or libraries) Display compilation warnings/errors 2. Run the compiled programs. 3. Debug the compiled programs. Use breakpoints, step through code. View call stack. View and modify values of local and global variables. View disassembly. 4. Use the Syntax highlighting and Code completion features of Visual Studio for the following subset of the Free Pascal language: Basic statements (assignments, subroutine calls) Conditions (if-then-else, switch-case) Loops (for, while, repeat-until) Expressions (arithmetic and logical operators) Subprograms (procedures, functions) Variables, constants Custom types (arrays, simple records, pointers to records) The implementation consists of multiple components integrated into Visual Studio via the COM (Common Object Model) and MEF (Managed Extension Framework) frameworks. These components are The Project System component, which adds the Free Pascal project and handles all project interactions (project creation, build initiation, debug session initiation, project settings, etc.) MSBuild is used as underlying build system, with Free Pascal compiler (fpc.exe) as the underlying compiler. The MIEngine debug engine (a debug engine is an intermediate layer between Visual Studio and underlying debugger) component is used together with GNU Debugger (gdb.exe) to debug the applications. The Code analysis component, which is responsible for creating a custom Abstract Syntax Tree from the user’s source code. The component uses a custom recursive-descent parser, which uses ANTLR4 generated lexer. The Syntax Highlighting component, which uses the Abstract Syntax Tree generated by the Code analysis component to tag (mark) pieces of source code (e.g. “Keyword”, “Comment”). These tags are then used in combination with current Visual Studio settings (e.g. theme) to highlight the source code. The Code completion component, which analyses the standard Free Pascal library files (units) using ppudump.exe and the Abstract Syntax Tree generated by the Code analysis component to provide context-aware code completion. The following figure shows the execution flows between our extension and the external code (i.e. Visual Studio 2015, MSBuild, fpc.exe, cmd.exe, gdb.exe). Notice that the syntax highlighting and code completion features do not interact with the Free Pascal Project, but only with Free Pascal source code (files with .pas extension). Therefore any project (including C# projects) can benefit from our Free Pascal syntax highlighting and code completion implementation, as long as the file has .pas extension. 1.Breakpoints, stepping through the code 2.Call stack 3.Disassembly Additional Features 4.Expression evaluation 5.Registers Borland Pascal IDE Lazarus IDE Current IDEs are obsolete! We have created a Visual Studio 2015 extension which adds all the features mentioned in Goals to the Visual Studio 2015 IDE. Code Completion Top: keywords Middle: custom identifiers Bottom: Standard library identifiers Compiler generated warnings and errors 1 4 2 3 5
1

FPVS Free Pascal Visual Studio Integration · Pascal programming using modern IDE The Pascal programming language was designed and is still used to this day to teach procedural imperative

Apr 02, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: FPVS Free Pascal Visual Studio Integration · Pascal programming using modern IDE The Pascal programming language was designed and is still used to this day to teach procedural imperative

FPVS Free Pascal Visual Studio Integration

Author: Václav Čamra | Supervisor: Mgr. Pavel Ježek, Ph. D. | 2017

Introduction Architecture

Pascal programming using modern IDE

The Pascal programming language was designed and is still used to this day to teach procedural imperative programming. However, there are no modern high quality integrated development environments (IDEs) that could be used by students to write in the Pascal programming language.

The major goal of this thesis was to fix this problem by creating a Visual Studio 2015 extension which would integrate Free Pascal programming language into Visual Studio IDE.

GoalsThe goal of this thesis was to create a Visual Studio extension which would allow students to:

1. Compile Free Pascal programs.• Only single file programs (i.e. no units or libraries)• Display compilation warnings/errors

2. Run the compiled programs.3. Debug the compiled programs.• Use breakpoints, step through code.• View call stack.• View and modify values of local and global variables.• View disassembly.

4. Use the Syntax highlighting and Code completion features of Visual Studio for the following subset of the Free Pascal language:

• Basic statements (assignments, subroutine calls)• Conditions (if-then-else, switch-case)• Loops (for, while, repeat-until)• Expressions (arithmetic and logical operators)• Subprograms (procedures, functions)• Variables, constants• Custom types (arrays, simple records, pointers to

records)

The implementation consists of multiple components integrated into Visual Studio via the COM (Common Object Model) and MEF (Managed Extension Framework) frameworks. These components are▪ The Project System component, which adds the Free Pascal project and handles all project

interactions (project creation, build initiation, debug session initiation, project settings, etc.)• MSBuild is used as underlying build system, with Free Pascal compiler (fpc.exe) as the

underlying compiler.▪ The MIEngine debug engine (a debug engine is an intermediate layer between Visual Studio

and underlying debugger) component is used together with GNU Debugger (gdb.exe) to debug the applications.

▪ The Code analysis component, which is responsible for creating a custom Abstract Syntax Tree from the user’s source code. The component uses a custom recursive-descent parser, which uses ANTLR4 generated lexer.

▪ The Syntax Highlighting component, which uses the Abstract Syntax Tree generated by the Code analysis component to tag (mark) pieces of source code (e.g. “Keyword”, “Comment”). These tags are then used in combination with current Visual Studio settings (e.g. theme) to highlight the source code.

▪ The Code completion component, which analyses the standard Free Pascal library files (units) using ppudump.exe and the Abstract Syntax Tree generated by the Code analysis component to provide context-aware code completion.

The following figure shows the execution flows between our extension and the external code (i.e. Visual Studio 2015, MSBuild, fpc.exe, cmd.exe, gdb.exe). Notice that the syntax highlighting and code completion features do not interact with the Free Pascal Project, but only with Free Pascal source code (files with .pas extension). Therefore any project (including C# projects) can benefit from our Free Pascal syntax highlighting and code completion implementation, as long as the file has .pas extension.

1.Breakpoints, stepping through the code

2.Call stack3.Disassembly

Additional Features4.Expression evaluation5.Registers

Borland Pascal IDE

Lazarus IDE

CurrentIDEs are obsolete!

We have created a Visual Studio 2015 extension which adds all the features mentioned in Goals to the Visual Studio 2015 IDE.

Code Completion

• Top: keywords• Middle: custom

identifiers• Bottom:

Standard library identifiers

Compiler generatedwarnings and errors

1

4

2

3

5