Giter VIP home page Giter VIP logo

extended-xyz's Introduction

Extended XYZ formal grammar and parser

This repository contains a BNF-like formal grammar for the extended XYZ format, created from the plain text specification at https://github.com/libAtoms/extxyz.

It also contains a parser for this grammar implemented in C, and a Python binding to the C parser.

Installing the Python module:

python setup.py install
# or
pip install .

Example usage:

from exyz import parse_comment_line


line = (
    'Properties=species:S:1:pos:R:3 s=string s2="test \\" string" b=T r=3.42 i=-33 '
    + 'a_i=[3, 4, 5] a_r=[-22, 4.2] a_b="T T F" a_s={a b c}'
)
properties, info = parse_comment_line(line)

print("Atomic properties:")
print(properties.to_dict())
# output:
# {'species': {'type': 'string', 'count': 1}, 'pos': {'type': 'real', 'count': 3}}

print("\nFrame properties:")
print(info.to_dict())
# output:
# {'s': 'string', 's2': 'test " string', 'b': True, 'r': 3.42, 'i': -33,
# 'a_i': array([3, 4, 5]), 'a_r': array([-22. ,   4.2]),
# 'a_b': array([ True,  True, False]), 'a_s': array(['a', 'b', 'c'], dtype='<U1')}

Installing the C library:

TODO

Running Python tests:

TODO

Running C tests:

mkdir build && cd build
cmake -DEXYZ_BUILD_TESTS=ON -DEXYZ_SANITIZERS=ON ..
make
ctest

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.