Configuration for Debugging the Pony Compiler in Visual Studio Code on Windows

For debugging the Pony compiler on Windows I use the following configuration files in the .vscode directory of my cloned ponyc git repo.

I also use the Pony Syntax Colorizer for syntax highlighting in Pony programs.

Updated: updated tasks.json for more recent VSCode versions.

c_cpp_properties.json:

{
  "configurations": [
    {
      "name": "Win32",
      "includePath": [
        "${workspaceRoot}/build/debug-llvm-3.9.1/ThirdParty/lib/LLVM-3.9.1-Debug/include",
        "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include",
        "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
        "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
        "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
        "${workspaceRoot}/src/common",
        "${workspaceRoot}/src/libponyrt"
      ],
      "defines": [
        "PONY_VERSION=\"0.20.0\"",
        "LLVM_VERSION=\"3.9.1\"",
        "PONY_COMPILER=\"msvc\"",
        "PONY_BUILD_CONFIG=\"debug\"",
        "PONY_LLVM=391",
        "DEBUG",
        "_DEBUG",
        "_MSC_VER=1900",
        "UNICODE"
      ],
      "browse": {
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": "C:/Users/Gordon/Dev/pony/ponyc/.vscode/browse/.browse.VC.db",
        "path": [
          "${workspaceRoot}/build/debug-llvm-3.9.1/ThirdParty/lib/LLVM-3.9.1-Debug/include",
          "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include",
          "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
          "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
          "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
          "${workspaceRoot}/src"
        ]
      },
      "intelliSenseMode": "msvc-x64"
    }
  ],
  "version": 3
}

Obviously the version numbers and directory names for LLVM, Visual Studio and Windows SDK will need to be updated for your particular installation.

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Ponyc",
      "type": "cppvsdbg",
      "request": "launch",
      "program": "${workspaceRoot}/build/debug-llvm-3.9.1/ponyc.exe",
      "args": [ ],
      "stopAtEntry": false,
      "cwd": "${workspaceRoot}",
      "environment": [
        {
          "name": "PONYPATH",
          "value": ""
        }
      ],
      "externalConsole": false
    },
    {
      "name": "Attach to Process",
      "type": "cppvsdbg",
      "request": "attach",
      "processId": "${command:pickProcess}"
    }
  ]
}

This provides two launch tasks, one for the Pony compiler, and one for attaching to a running program.

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "distclean",
      "command": "${workspaceRoot}/make.bat",
      "args": [
        "distclean"
      ],
      "type": "shell",
      "group": "none",
      "problemMatcher": []
    },
    {
      "label": "configure",
      "command": "${workspaceRoot}/make.bat",
      "args": [
        "configure"
      ],
      "type": "shell",
      "group": "none",
      "problemMatcher": []
    },
    {
      "label": "clean",
      "command": "${workspaceRoot}/make.bat",
      "args": [
        "clean",
        "--config=debug"
      ],
      "type": "shell",
      "group": "none",
      "problemMatcher": []
    },
    {
      "label": "build",
      "command": "${workspaceRoot}/make.bat",
      "args": [
        "build",
        "--config=debug"
      ],
      "type": "shell",
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": "$msCompile"
    },
    {
      "label": "test",
      "command": "${workspaceRoot}/make.bat",
      "args": [
        "build",
        "test",
        "--config=debug"
      ],
      "type": "shell",
      "group": {
        "kind": "test",
        "isDefault": true
      },
      "problemMatcher": "$msCompile"
    }
  ]
}

This will provide tasks for building and testing ponyc in debug mode.

settings.json

{
  "files.associations": {
    "*.h": "cpp",
    "*.c": "cpp"
  }
}

Windows builds must use C++ for all source files.

PEG Parser Library for Pony

I have recently released a PEG parser library for the Pony programming language: Kiuatan (“horse” or “pony” in Chinook Jargon). This is mostly a learning exercise for me. It doesn’t make use of any of Pony’s actor model functionality.

Kiuatan (“horse” or “pony” in Chinook Jargon) is a library for building and running parsers in the Pony programming language.

Kiuatan uses Parsing Expression Grammar semantics, which means:

  • Choices are ordered, i.e. the parser will always try to parse alternatives in the order they are declared.
    • Parsers do not backtrack from successful choices.
    • Sequences are greedy, i.e. the parser will not backtrack from the end of a sequence.
  • Kiuatan parsers are “packrat” parsers; they memoize intermediate results, resulting in linear-time parsing.
  • Parsers use Mederios et al’s algorithm to handle unlimited left-recursion.

Building the Pony compiler on Windows

Update 2017-01

I have made a vastly simpler build system for Pony on Windows.

Original

I have been taking a look at the very interesting Pony programming language in my copious free time for a couple of weeks now. It’s fairly straightforward to build on Ubuntu. Here’s how I built it on Windows 10:

This process uses GnuWin32, which LLVM recommends, to provide unix utils; your mileage may vary with MSYS or Cygwin.

Build LLVM:

  • Install GnuWin32 via the GetGnuWin32 tool; make sure it’s in your PATH.
  • Install Python (I used 3.5.1; 2.7 is supposed to work as well); make sure it’s in PATH.
  • Installed CMake; make sure it’s in PATH.
  • Get the LLVM source. I used the tarball of 3.7.1 (requireds 7-zip to open on Windows).
  • Make sure you have VS2015 with C++ installed.
  • Generate LLVM VS2015 configuration with CMake. I used the GUI to configure and generate the VS projects; make sure you use the 64-bit generator (“Visual Studio 14 2015 Win64”), and set the CMAKE_INSTALL_PREFIX to where you want LLVM to live.
  • Build the INSTALL project in the LLVM solution.

Build PonyC:

  • Get the PreMake5 executable, and put it somewhere in your PATH.
  • Get the PonyC source.
  • Run premake5.exe --with-tests --to=..\vs vs2015 to generate Ponyc.sln.
  • Changed the Character Set property of each project in the PonyC solution to Not Set.
  • Build Pony.sln

In order to run the pony compiler, you’ll need a few libraries in your environment. I have made a utility that will get the libraries and set up your environment:

  • Install 7-Zip, make sure it’s in PATH.
  • Open a VS2015 x64 Native Tools Command Prompt (things will not work correctly otherwise!) and run:


    > git clone git@github.com:kulibali/ponyc-windows-libs.git
    > cd ponyc-windows-libs
    > .\getlibs.bat
    > .\setenv.bat

  • Now you can run the pony compiler and tests:


    > cd path_to_pony_source
    > build\release\testc.exe
    > build\release\testrt.exe
    > build\release\ponyc.exe -d -s packages\stdlib
    > .\stdlib