Skip to content

Instantly share code, notes, and snippets.

View Virtlink's full-sized avatar

Daniel A.A. Pelsmaeker Virtlink

View GitHub Profile

Origin Tracking

Origin tracking is the idea to build an origin relation between input and output terms of a transformation in a term transformation system (TRS). It was first proposed by Van Deursen et al. in 1993 in the eponymous article. The origin relation can be used to traverse from a result term, to the term before the final transformation happened. This relation can be followed further, all the way back to the original input term before all transformations. Examples of uses for this relation (from the paper) are: constructing language-specific debuggers, visualising program execution, and associating positional information with messages in error reports. The first two examples relate to using the TRS to implement evaluation (interpretation) of a programming language, where the abstract syntax tree (AST) of a program is a term that is transformed to execute it. The origin relation allows a debugger or visualiser to show the execution one step at a time. The third example uses the origin relation tran

@Virtlink
Virtlink / pom.xml
Last active September 14, 2017 16:36
POM file for IntelliJ plugin development with Maven support
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.contoso</groupId>
<artifactId>org.contoso.my-plugin.intellij</artifactId>
<version>0.1.0-alpha</version>
<packaging>jar</packaging>
@Virtlink
Virtlink / CircularArray.cs
Created March 17, 2014 02:04
Helper methods for copying data between linear and circular arrays.
using System;
using System.Diagnostics.Contracts;
namespace Virtlink
{
/// <summary>
/// Helper methods for working with circular arrays.
/// </summary>
/// <example>
/// Usage example:
@Virtlink
Virtlink / StreamExtensions.cs
Last active August 29, 2015 13:56
Copies part of a stream to another stream.
using System;
using System.Diagnostics.Contracts;
using System.IO;
namespace Virtlink
{
/// <summary>
/// Extension methods for <see cref="Stream"/> objects.
/// </summary>
/// <example>
@Virtlink
Virtlink / NestedArray.cs
Last active August 29, 2015 13:56
Helper methods for creating nested arrays.
using System;
using System.Diagnostics;
using System.Linq;
namespace Virtlink
{
/// <summary>
/// Helper methods for creating nested arrays.
/// </summary>
/// <example>
@Virtlink
Virtlink / TypeSwitch.cs
Last active March 9, 2019 17:11
Switch on type. The order of the Case() methods is important.
using System;
namespace Virtlink
{
/// <summary>
/// Executes a particular piece of code based on the type of the argument.
/// </summary>
/// <example>
/// Usage example:
/// <code>
@Virtlink
Virtlink / TextToNotepad.cs
Last active August 11, 2020 22:11
Sends `Hello world!` to one instance of notepad that is currently running.
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
namespace Virtlink
{
public sealed class Program
{
#region PInvoke
@Virtlink
Virtlink / StringFormatting.CodeContracts.cs
Last active December 28, 2015 16:58
Better string formatting extension methods.
using System;
using System.Diagnostics.Contracts;
using System.Globalization;
namespace Virtlink
{
/// <summary>
/// String extension methods.
/// </summary>
/// <example>
@Virtlink
Virtlink / ToSZArray.cs
Last active December 28, 2015 06:29
Copies an array with rank 1 and any lower-bound into a single-dimensional zero-based array (SZ-array) with lower bound zero.
using System;
namespace Virtlink
{
/// <summary>
/// Helper methods for arrays.
/// </summary>
/// <example>
/// Usage example:
/// <code>