How to use the tau-prolog.type function in tau-prolog

To help you get started, we’ve selected a few tau-prolog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yarnpkg / berry / packages / plugin-constraints / sources / tauModule.ts View on Github external
import {Project}      from '@yarnpkg/core';
import {PortablePath} from '@yarnpkg/fslib';
import getPath        from 'lodash/get';
import pl             from 'tau-prolog';

// eslint-disable-next-line @typescript-eslint/camelcase
const {is_atom: isAtom} = pl.type;

function prependGoals(thread: pl.type.Thread, point: pl.type.State, goals: pl.type.Term[]): void {
  thread.prepend(goals.map(
    goal => new pl.type.State(
      point.goal.replace(goal),
      point.substitution,
      point,
    ),
  ));
}

const projects = new WeakMap();

function getProject(thread: pl.type.Thread): Project {
  const project = projects.get(thread.session);
github yarnpkg / berry / packages / plugin-constraints / sources / Constraints.ts View on Github external
function extractErrorImpl(value: any): any {
  if (value instanceof pl.type.Num)
    return value.value;

  if (value instanceof pl.type.Term) {
    if (value.args.length === 0)
      return value.id;

    switch (value.indicator) {
      case `throw/1`:
        return extractErrorImpl(value.args[0]);
      case `error/1`:
        return extractErrorImpl(value.args[0]);
      case `error/2`:
        return Object.assign(extractErrorImpl(value.args[0]), ...extractErrorImpl(value.args[1]));
      case `syntax_error/1`:
        return new ReportError(MessageName.PROLOG_SYNTAX_ERROR, `Syntax error: ${extractErrorImpl(value.args[0])}`);
      case `existence_error/2`:
        return new ReportError(MessageName.PROLOG_EXISTENCE_ERROR, `Existence error: ${extractErrorImpl(value.args[0])} ${extractErrorImpl(value.args[1])} not found`);
      case `line/1`:
        return {line: extractErrorImpl(value.args[0])};
github yarnpkg / berry / packages / plugin-constraints / sources / Constraints.ts View on Github external
function extractErrorImpl(value: any): any {
  if (value instanceof pl.type.Num)
    return value.value;

  if (value instanceof pl.type.Term) {
    if (value.args.length === 0)
      return value.id;

    switch (value.indicator) {
      case `throw/1`:
        return extractErrorImpl(value.args[0]);
      case `error/1`:
        return extractErrorImpl(value.args[0]);
      case `error/2`:
        return Object.assign(extractErrorImpl(value.args[0]), ...extractErrorImpl(value.args[1]));
      case `syntax_error/1`:
        return new ReportError(MessageName.PROLOG_SYNTAX_ERROR, `Syntax error: ${extractErrorImpl(value.args[0])}`);
      case `existence_error/2`:
github yarnpkg / berry / packages / plugin-constraints / sources / tauModule.ts View on Github external
    goal => new pl.type.State(
      point.goal.replace(goal),
      point.substitution,
      point,
    ),
  ));

tau-prolog

An open source Prolog interpreter in JavaScript

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis