-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from carocad/antlr-js
Support for Browser environments
- Loading branch information
Showing
19 changed files
with
286 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
;; https://figwheel.org/docs/testing.html | ||
^{:auto-testing true | ||
:watch-dirs ["src/clojure" "test"]} | ||
{:main parcera.core | ||
:npm-deps {"antlr4" "^4.7.2"} | ||
:install-deps true | ||
:infer-externs true} | ||
;:target :nodejs | ||
;{:file "src/javascript/parcera/antlr/ClojureLexer.js" | ||
; :provides ["antlr.clojure.lexer"] | ||
; :module-type :commonjs} | ||
;{:file "src/javascript/parcera/antlr/Clojure.Parser.js" | ||
; :provides ["antlr.clojure.parser"] | ||
; :module-type :commonjs}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Utility module to load all antlr related functionality; including | ||
* the generated one. | ||
* | ||
* This file will then be passed through Webpack to create a single | ||
* bundle | ||
*/ | ||
const antlr4 = require('antlr4') | ||
const {ClojureLexer} = require('../src/clojure/parcera/antlr/js/ClojureLexer') | ||
const {ClojureParser} = require('../src/clojure/parcera/antlr/js/ClojureParser') | ||
|
||
const reader = { | ||
charStreams: (input) => new antlr4.CharStreams.fromString(input), | ||
lexer: (chars) => new ClojureLexer(chars), | ||
tokens: (lexer) => new antlr4.CommonTokenStream(lexer), | ||
parser: (tokens) => new ClojureParser(tokens), | ||
} | ||
|
||
module.exports = reader | ||
// global.ClojureReader = reader | ||
|
||
// console.log(`DONE 💫`) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
mode: "production", | ||
entry: path.resolve(__dirname, './clojureReader.js'), | ||
output: { | ||
filename: 'clojure.reader.bundle.js', | ||
path: path.resolve(__dirname, '../src/clojure/parcera/antlr/js'), | ||
// the url to the output directory resolved relative to the HTML page | ||
library: "ClojureReader", | ||
// the name of the exported library | ||
libraryTarget: "commonjs2", | ||
}, | ||
target: 'web', | ||
node: { | ||
module: "empty", | ||
net: "empty", | ||
fs: "empty" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
; NOTE: I feel this more as a hack than as an actual solution.} | ||
; Ideally I should just let ClojureScript import the lexer and parser | ||
; from a browser perspective. However it seems that the Closure compiler | ||
; doesnt like conditional imports so it throws saying that 'fs' is not | ||
; defined which is clearly a node.js dependency. | ||
; On the other hand, if I pass the module as node.js target then the Closure | ||
; compiler corrupts the source code which makes it unusable :( | ||
{:foreign-libs [{:file "parcera/antlr/js/clojure.reader.bundle.js" | ||
:provides ["antlr.clojure.reader"] | ||
:module-type :commonjs}]} |
Oops, something went wrong.