No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A reference parser for the Koi language.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

koi-reference-parser¶ ↑

This is the reference parser implementation for the programming language Koi. The parser is implemented using a Parsing Expression Grammar (PEG) that is run by a PEG engine called Treetop.

Example¶ ↑

The parser takes a text string containing a program like:

test = 1 + 2

And turns it into an Abstract Syntax Tree (AST) that unambiguously represents the program’s structure and meaning. The AST is represented as a series of Ruby objects that subclass a generic SyntaxNode class. The code above transformed into AST would look like:

<Block "test = 1 + 2">
  <Statement "test = 1 + 2">
    <Assignment "test = 1 + 2">
      <Identifier "test">
      <AssignmentOperator "=">
      <Expression "1 + 2">
        <AdditiveExpression "1 + 2">
          <IntegerLiteral "1">
          <AdditionOperator "+">
          <IntegerLiteral "2">

The AST is also available in a far more portable format based on nested hashes by calling the to_hash method on the root AST node.

Installation¶ ↑

This parser is normally installed as part of Koi’s default toolchain. However if you would like to install it on it’s own you can do so by installing the gem like so:

gem install koi-reference-parser

Usage¶ ↑

require 'rubygems'
require 'koi-reference-parser'

include KoiReferenceParser

ast = Parser.parse( program_text )

# Get the AST as a portable nested hash
ast_hash = ast.to_hash

Author & Credits¶ ↑

Author

Aaron Gough

Copyright © 2010 Aaron Gough (thingsaaronmade.com), released under the MIT license