All Projects → clojure-emacs → parseclj

clojure-emacs / parseclj

Licence: GPL-3.0 License
Clojure Parser for Emacs Lisp

Programming Languages

emacs lisp
2029 projects

Projects that are alternatives of or similar to parseclj

ruby ast visualizer
🌲 Ruby AST Visualizer. Based on Parser.
Stars: ✭ 28 (-36.36%)
Mutual labels:  ast
yode
Yode - Focused Code Editing
Stars: ✭ 28 (-36.36%)
Mutual labels:  ast
xast
Extensible Abstract Syntax Tree
Stars: ✭ 32 (-27.27%)
Mutual labels:  ast
js-ziju
Compile javascript to LLVM IR, x86 assembly and self interpreting
Stars: ✭ 112 (+154.55%)
Mutual labels:  ast
vast
A simple tool for vlang, generate v source file to AST json file
Stars: ✭ 23 (-47.73%)
Mutual labels:  ast
lpegrex
Parse programming languages syntax into an AST using PEGs with ease (LPeg Extension).
Stars: ✭ 32 (-27.27%)
Mutual labels:  ast
kolasu
Kotlin Language Support – AST Library
Stars: ✭ 45 (+2.27%)
Mutual labels:  ast
ast-builder
Build your ASTs directly from code
Stars: ✭ 18 (-59.09%)
Mutual labels:  ast
parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (-15.91%)
Mutual labels:  ast
ast ninja
The Elixir AST explorer
Stars: ✭ 59 (+34.09%)
Mutual labels:  ast
hxjsonast
Parse JSON into position-aware AST with Haxe!
Stars: ✭ 28 (-36.36%)
Mutual labels:  ast
impast
A library for package AST importing
Stars: ✭ 26 (-40.91%)
Mutual labels:  ast
asty
Abstract Syntax Tree (AST) Data Structure
Stars: ✭ 28 (-36.36%)
Mutual labels:  ast
node-typescript-parser
Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.
Stars: ✭ 121 (+175%)
Mutual labels:  ast
esvalid
confirm that a SpiderMonkey format AST represents an ECMAScript program
Stars: ✭ 24 (-45.45%)
Mutual labels:  ast
rector-laravel
Rector upgrades rules for Laravel
Stars: ✭ 75 (+70.45%)
Mutual labels:  ast
verilogAST-cpp
C++17 implementation of an AST for Verilog code generation
Stars: ✭ 14 (-68.18%)
Mutual labels:  ast
valast
Convert Go values to their AST
Stars: ✭ 251 (+470.45%)
Mutual labels:  ast
tsquery-playground
Playground for TSQuery
Stars: ✭ 30 (-31.82%)
Mutual labels:  ast
astra
Astra: a Java tool for analysing and refactoring Java source code
Stars: ✭ 35 (-20.45%)
Mutual labels:  ast

Build Status

Clojure parser for Emacs Lisp

parseclj is an Emacs Lisp library for parsing Clojure code and EDN data. It supports several input and output formats, all powered by the same shift-reduce parser function.

Take a look at the design document for more details.

parseclj is in alpha state right now, its API might be subject to change.

Installation

Available on the major package.el community maintained repos - MELPA Stable and MELPA repos.

MELPA Stable is the recommended repo as it has the latest stable version. MELPA has a development snapshot for users who don't mind (infrequent) breakage but don't want to run from a git checkout.

You can install parseclj using the following command:

M-x package-install [RET] parseclj [RET]

or if you'd rather keep it in your dotfiles:

(unless (package-installed-p 'parseclj)
  (package-install 'parseclj))

If the installation doesn't work try refreshing the package list:

M-x package-refresh-contents

Usage

parseclj contains function that return an AST that, for example, given as input (1 2 [:a :b :c]), it looks like this:

((:node-type . :root)
 (:position . 1)
 (:children ((:node-type . :list)
             (:position . 1)
             (:children ((:node-type . :number)
                         (:position . 2)
                         (:form . "1")
                         (:value . 1))
                        ((:node-type . :number)
                         (:position . 4)
                         (:form . "2")
                         (:value . 2))
                        ((:node-type . :vector)
                         (:position . 6)
                         (:children ((:node-type . :keyword)
                                     (:position . 7)
                                     (:form . ":a")
                                     (:value . :a))
                                    ((:node-type . :keyword)
                                     (:position . 10)
                                     (:form . ":b")
                                     (:value . :b))
                                    ((:node-type . :keyword)
                                     (:position . 13)
                                     (:form . ":c")
                                     (:value . :c))))))))

In order to use any of these functions, you first need to require it:

(require 'parseclj)

And then you will have the following functions at your disposal:

  • parseclj-parse-clojure &rest string-and-options

    When no arguments, parses Clojure source code into an AST and returns it. When given a string as a first argument, parses it and returns the corresponding AST.

    A list of options can be passed down to the parsing process, particularly:

    • :lexical-preservation: a boolean value to retain whitespace, comments, and discards. Defaults to nil.
    • :fail-fast: a boolean value to raise an error when encountering invalid syntax. Defaults to t.

    Examples:

    (parseclj-parse-clojure) ;; will parse clojure code in the current buffer and return an AST
    (parseclj-parse-clojure "(1 2 3)")  ;; => ((:node-type . :root) ... )
    (parseclj-parse-clojure :lexical-preservation t) ;; will parse clojure code in current buffer preserving whitespaces, comments and discards

    Note: there's an open issue to extend this API to parse clojure code within some boundaries of a buffer. Pull requests are welcome.

  • parseclj-unparse-clojure ast

    Transform the given AST into Clojure source code and inserts it into the current buffer.

  • parseclj-unparse-clojure-to-string ast

    Transfrom the given AST into Clojure source code and returns it as a string.

License

© 2017-2021 Arne Brasseur and contributors.

Distributed under the terms of the GNU General Public License 3.0 or later. See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].