Skip to content

codexstanford/epilog-lexers-parsers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Epilog Lexers & Parsers

A library with lexers and parsers for the Epilog programming language.

Installation (package is not published on NPM yet, so the following will not work)

bun add epilog-lexers-parsers

Usage

Download the latest release. The library exports four main functions (for the imports to work, make sure to colocate the release file with your code):

Lexers

import { datasetLexer, rulesetLexer } from "./epilog-lexers-parsers.js";

// Tokenize a dataset
const datasetTokens = datasetLexer("father(john, mary).");
// Returns array of tokens: [{type: "CONSTANT", content: "father"}, {type: "LEFT_PAREN"}, ...]

// Tokenize a ruleset
const rulesetTokens = rulesetLexer("ancestor(X, Y) :- parent(X, Y).");
// Returns array of tokens: [{type: "CONSTANT", content: "ancestor"}, {type: "LEFT_PAREN"}, ...]

Parsers

import { parseDataset, parseRuleset } from "./epilog-lexers-parsers.js";

// Parse a dataset (requires tokens from datasetLexer)
const datasetAst = parseDataset(datasetTokens);
// Returns AST with type "DATASET" and children representing facts

// Parse a ruleset (requires tokens from rulesetLexer)
const rulesetAst = parseRuleset(rulesetTokens);
// Returns AST with type "RULESET" and children representing rules, operations, and definitions

Development

Prerequisites

  • Bun runtime
  • Git

Setup

# Clone the repository
git clone [repository-url]
cd epilog-lexers-parsers

# Install dependencies
bun install

Running Tests

bun test

Creating a Release

To create a new release:

  1. Make sure all your changes are committed and pushed
  2. Create and push a new tag with semantic versioning:
    git tag v1.0.0  # Replace with appropriate version
    git push origin v1.0.0
  3. The GitHub Action will automatically:
    • Run all tests
    • Build the project
    • Create a new GitHub release
    • Upload build artifacts

The release will be available in the GitHub repository's Releases section.

License

This is “work made for hire” within the meaning of the Copyright Act of 1976, as amended from time to time. The Software is the sole property of The Board of Trustees of the Leland Stanford Junior University. It was initially developed by Paul F. Welter (bayshore AI).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published