Giter VIP home page Giter VIP logo

autocomf's Introduction

AUTOCOMF - Automatic Configuration from Comments

AUTOCOMF is a programming language that presents a configuration UI based on annotations in a source file. The configuration specified by the user is then incorporated by automatically modifying the source file.

AUTOCOMF can be used seamlessly with any programming language or configuration language, since it is written wholly within the comment syntax of the host language.

AUTOCOMF has incorporates several attractive qualities:

  • Self-modifying code.

  • Semantically meaningful comments.

  • ALL CAPS KEYWORDS.

  • A human-friendly, intuitive, unclearly specified syntax.

  • Named in honour of the universally loved autoconf system.

AUTOCOMF is guaranteed free of defects, but user error is always a possibility. In the best Unix tradition, AUTOCONF will irrevocably change the input file, without any backup! Make sure you understand the completely precise and unambiguous specification before running it on files you care about!

AUTOCOMF was developed as a contribution to Langjam #1.

How does AUTOCOMF work?

AUTOCOMF code is embedded inside comments of any other programming language or config file, although currently limited to the ones that support line comments (such as # for shell scripts, ; for Lisp, or // for C). The input file must somewhere contain the string AUTOCOMF COMMENT LINE foo, after which foo is taken to be the line comment marker for the file. This string is typically itself embedded within a line comment. For example:

# AUTOCOMF COMMENT LINE #

The rest of the examples will assume that # is the line comment marker.

An AUTOCOMF program consists of variable definitions and directives. When an AUTOCOMF program is run, the variable definitions will be collected and presented to the user, who can then interactively provide values for them. Here is an example of a variable definition:

# AUTOCOMF VAR myForegroundColour REGEX red|green|blue|purple|cyan|white|yellow

This defines a variable called myForegroundColour, whose value must match the regular expression provided.

After values have been provides for all the variables, the directives are then interpreted. Each directive controls the following (presumably non-comment) line. For example:

# AUTOCOMF USE fg=$¤myForegroundColour¤
fg=$red

The line fg=$red will be replacd by fg=$foo, where foo is the value of the myForegroundColour specified by the user. Note the use of the ¤ character to bracket AUTOCOMF-level variables - because they are language-unspecific!

After these substitutions are done, the source file will be overwritten with the result.

Examples

They are here.

Compiling and using

You'll need a Haskell setup (install ghc and cabal from your package manager or use ghcup). Then build with:

$ cabal update
$ cabal build

And run an example program with:

$ cabal run autocomf examples/bashrc

autocomf's People

Contributors

athas avatar munksgaard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.