All Projects → carocad → parcera

carocad / parcera

Licence: LGPL-3.0 license
Grammar-based Clojure(script) parser

Programming Languages

clojure
4091 projects
ANTLR
299 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to parcera

java-ast
Java Parser for JavaScript/TypeScript (based on antlr4ts)
Stars: ✭ 58 (-42%)
Mutual labels:  ast, antlr4
kolasu
Kotlin Language Support – AST Library
Stars: ✭ 45 (-55%)
Mutual labels:  ast, antlr4
react-viewer
Online EPUB/Comics viewer
Stars: ✭ 52 (-48%)
Mutual labels:  reader
rector-doctrine
Rector upgrades rules for Doctrine
Stars: ✭ 37 (-63%)
Mutual labels:  ast
language-rust
Parser and pretty-printer for the Rust language
Stars: ✭ 78 (-22%)
Mutual labels:  ast
subpy
Python subsets
Stars: ✭ 41 (-59%)
Mutual labels:  ast
antlr4-tool
A useful Antlr4 tool with full TypeScript support
Stars: ✭ 34 (-66%)
Mutual labels:  antlr4
react-native-config-reader
🛠 Easily access any of the build configs defined in build.gradle or info.plist from your JS code.
Stars: ✭ 44 (-56%)
Mutual labels:  reader
sql-parser
Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.
Stars: ✭ 230 (+130%)
Mutual labels:  ast
snapdragon-util
Utilities for the snapdragon parser/compiler.
Stars: ✭ 17 (-83%)
Mutual labels:  ast
vscode-ast
Show JavaScript / TypeScript Abstract Syntax Tree
Stars: ✭ 34 (-66%)
Mutual labels:  ast
lilt
LILT: noun, A characteristic rising and falling of the voice when speaking; a pleasant gentle accent.
Stars: ✭ 18 (-82%)
Mutual labels:  ast
open-fortran-parser-xml
XML output generator for Open Fortran Parser, and Python wrapper for it.
Stars: ✭ 21 (-79%)
Mutual labels:  ast
nast
A block-based intermediate representation for document-like content.
Stars: ✭ 35 (-65%)
Mutual labels:  ast
yahdl
A programming language for FPGAs.
Stars: ✭ 20 (-80%)
Mutual labels:  antlr4
codeparser
Parse Wolfram Language source code as abstract syntax trees (ASTs) or concrete syntax trees (CSTs)
Stars: ✭ 84 (-16%)
Mutual labels:  ast
macro-visit
A macro-based generic visitor generator
Stars: ✭ 23 (-77%)
Mutual labels:  ast
esp-idf-rc522
C library for interfacing ESP32 with MFRC522 RFID card reader, packaged as ESP-IDF component
Stars: ✭ 60 (-40%)
Mutual labels:  reader
mp4-rust
🎥 MP4 reader and writer library in Rust! 🦀
Stars: ✭ 149 (+49%)
Mutual labels:  reader
sass-lint-auto-fix
Automatically resolve s(a|c)ss linting issues
Stars: ✭ 93 (-7%)
Mutual labels:  ast

parcera

Build Status Clojars Project CljDoc

Grammar-based Clojure(script) parser.

Parcera can safely read any Clojure file without any code evaluation.

Parcera uses the wonderful Antlr4 as its parsing engine and focuses on the grammar definition instead.

If you are interested in the grammar definition check Clojure.g4.

setup

  • Java

Add [org.antlr/antlr4-runtime "4.7.1"] to your dependencies in addition to parcera. This is to avoid adding an unnecessary dependency for the JavaScript users.

  • Javascript

All necessary files are delivered with parcera. However, currently only Browser support has been tested.

  • Babashka

Check out babashka's pod for parcera. Made by @borkdude

usage

(ns example.core
  (:require [parcera.core :as parcera]))

;;parse clojure code from a string
(parcera/ast (str '(ns parcera.core
                     (:require [clojure.data :as data]
                               [clojure.string :as str]))))

;; => returns a data structure with the result from the parser
(:code
 (:list
  (:symbol "ns")
  (:whitespace " ")
  (:symbol "parcera.core")
  (:whitespace " ")
  (:list
   (:keyword ":require")
   (:whitespace " ")
   (:vector (:symbol "clojure.data") (:whitespace " ") (:keyword ":as") (:whitespace " ") (:symbol "data"))
   (:whitespace " ")
   (:vector (:symbol "clojure.string") (:whitespace " ") (:keyword ":as") (:whitespace " ") (:symbol "str")))))
   
;; get meta data from the parsed code
(meta (second (parcera/ast (str :hello))))
#:parcera.core{:start {:row 1, :column 0}, :end {:row 1, :column 6}}

;; convert an AST back into a string
(parcera/code [:symbol "ns"])
;; "ns"

contributing

  • to get you setup check the travis file which already contains a full setup from scratch.
  • the project contains a benchmark which should be the decision factor for performance issues.
  • please follow Clojure's Etiquete for issues and pull requests
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].