GitXplorerGitXplorer
r

gcl

public
60 stars
9 forks
8 issues

Commits

List of commits on branch master.
Unverified
4e3bccc978a9c60aaaffd20f6f291c4d23775cdf

Merge most important bits of bugfixes to 0.6.x branch

rrix0rrr committed 8 years ago
Unverified
4eb08e53b8da2c82285b8b6747223ea844ddc5ed

Add .values() method to Tuples, to quack more like dicts

rrix0rrr committed 8 years ago
Unverified
c00011972761f3ff1b302ca4a0b8e0eb38d64f31

Don't validate the outermost object in the LHS of an application

rrix0rrr committed 8 years ago
Unverified
5ea886f2fe24885c426501a2df35164f06335e59

Parsing performance improvements

rrix0rrr committed 8 years ago
Unverified
ea0e7fe8ba0d5312f77906e3414100f8cf12c63b

Merge tag '0.6.10'

rrix0rrr committed 8 years ago
Unverified
4f87cd6ce49089171df00b0a76038f2eb30a0513

Fix single-character comment bug, bump to 0.6.10

rrix0rrr committed 8 years ago

README

The README file for this repository.

gcl -- Generic Configuration Language

GCL is an declarative modeling language that can be dropped into any Python project. It supports dictionaries with name-value pairs, all the basic types you'd expect, lists, includes, and methods for abstraction.

The goal for GCL is to be a modeling language with lots of expressive power, intended to make complex configurations extremely DRY. Behavior is not part of the goal of the language; behavior and semantics are added by scripts that interpret the GCL model.

Documentation

Detailed documentation is available at http://gcl.readthedocs.org

Quick GCL showcase

GCL is built around named tuples, written with curly braces:

# This is a comment
# Various data types:
number = 1;
string =  'value';  # Strings can be doubly-quoted as well
bool =  true;       # Note: lowercase
expression = number * 2; 
list = [ 1, 2, 3 ];

Expressions:

a = 1 + 1;
b = 'foo' + 'bar';
c = 80 * '-';

d = inc(1);  # Function application
e = inc 1;   # Can omit parens with 1 argument

# Conditionals
allow_test_commands = if stage == 'alpha' then true else false;

# List comprehension
evens = [ x * 2 for x in [1, 2, 3, 4, 5] if x % 2 == 0 ];

Tuples and accessing tuple members:

tuple = {
  foo = 3;
}

that_foo = tuple.foo;

Includes and tuple composition:

http = include 'library/http.gcl';
server = http.Server {
    port = 8080;
}

Using the library

You now know enough GCL to get started. Using the library looks like this:

import gcl
from gcl import util

# Load and evaluate the given file
model = gcl.load('myfile.gcl')

# This gives you a dict-like object back, that you can just index
print(model['element'])

# Translate the whole thing to a Python dict (for example to convert to JSON)
dict_model = util.to_python(model)

import json
print(json.dumps(dict_model))

Requirements

  • Uses pyparsing.

Extra