Questions tagged [babel-babylon]

Babylon is a JavaScript parser used in Babel,js. It can parse source code into an abstract syntax tree (AST).

Babylon supports two API calls

babylon.parse(code, [options])
babylon.parseExpression(code, [options])

and generates an AST from a string containing Javascript code.

Github Page: https://github.com/babel/babylon

14 questions
12
votes
2 answers

How can I transform a custom AST into JS code

I am currently generating a custom AST from a new language specification I have designed. This custom AST contains different nodes that I have designed with all the information I need in order to now generate JavaScript code. For example: Say I have…
4
votes
1 answer

Why Babel uses a top down parser?

I'm studying compiler construction and naturally I'm also studying real world implementations of these concepts. One example of this is Babel's parser: Babylon. I went through Babylon's code and it appears to be using a Top Down parser with embedded…
3
votes
0 answers

How to transform literal function into AST using Babel

I'm trying to update a JS configuration object using Babel. For this, I created a Babel plugin that is used this way: const transform = require('@babel/standalone').transform const newCode = transform(code, { plugins: [ [ …
hypervillain
  • 393
  • 1
  • 5
  • 18
2
votes
2 answers

Using babel traverse to to get comments in AST

How do I traverse comments with babelTraverse? babelTraverse(nodes, { CommentBlock: (path) => { console.log(path) }, CommentLine: (path) => { console.log(path) } }) Error: You gave us a visitor for the node type CommentBlock but…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
2
votes
2 answers

Babel Plugin: How to insert a sibling node

It seems that path.insertAfter(), path.insertBefore(), path.unshiftContainer(), and path.pushContainer() only work with Statements. How do you insert nodes that are not Statements? In my case I am writing a babel jsx plugin and I am trying to insert…
curiousgeorge
  • 593
  • 1
  • 5
  • 14
2
votes
0 answers

Is it possible to convert Babylon parsed AST back to source code after modification?

I was trying to modify JavaScript source code by: parse source code with @babel/babylon and get the AST traverse AST with babel-traverse and do some modifications where needed turn AST back to JavaScript source code The first two steps is pretty…
aztack
  • 4,376
  • 5
  • 32
  • 50
1
vote
1 answer

Stopping/Restarting animation inside loop with Babylon.JS

I'm setting this loop up with three animations, the first one that runs on initial screen load (firstAnimation). Then the next two animations use callbacks to loop between themselves (slideAnimation -> rotateAnimation -> slideAnimation...) How can I…
alecbaldwin
  • 300
  • 2
  • 11
1
vote
1 answer

How to create an "Expression" with babylon?

I need to add an objectProperty, but it requires key and value: t.objectProperty(key, value, ...) And the value must be an "Expression". I assumed that it must be object expression: t.objectExpression(properties) Where "properties" must be an…
Alex Tumanov
  • 435
  • 1
  • 3
  • 16
0
votes
0 answers

How to mark 2 point and draw lines in betwwen them in babylonjs

Needto accomplish these kind of 3D box shapes and respective route paths (straight and curves) on this terrain
Akash AR
  • 39
  • 6
0
votes
1 answer

WebGL: INVALID_OPERATION: uniformMatrix4fv / [WebGL-00000A18072FEA00] GL_INVALID_OPERATION

I am currently developing an application that displays 360° images and I use the BabylonJS library for that. I have a navbar that allows me to navigate between the different 360 locations. But as soon as I change the 360 ​​image via the navbar, I…
AlaBaz
  • 21
  • 2
0
votes
1 answer

BABYLONJS : I need to create the 2D background stag of 720*480 and with responsive as per aspect ration of screen

Folks, I am currently using phaser js but now i am try to implement babylonjs, I need to create stage 720*480 static stage that will not transferred into 3D. Stage should be STILL. An it is responsive based on the aspect ratio of the browser or the…
Kothari Ankit
  • 296
  • 1
  • 4
  • 12
0
votes
1 answer

How to transpile VariableDeclarator to AssignmentExpression?

I'm trying to take something like var a = 5; and transpile it to something like thing.a = 5. Using this code below in my visitor, it tells me unexpected token . VariableDeclarator: { enter: function (path, state) { path.replaceWith( …
realisation
  • 634
  • 6
  • 18
0
votes
1 answer

has already been exported. Exported identifiers must be unique.Babel babylon error

I am .net developer i am new in nodejs enviroment I have a nodeJS project.It was work very well,I addes some feauture and I finished it.Then I deleted that project.Now I must install that project for add new feautures So I took project code in a…
user1688401
  • 1,851
  • 8
  • 47
  • 83
-1
votes
1 answer

check parameters of a function with Babel

I want to check parameters of a function to be in a range with babel. I mean I want to change the following code: function(arg1, arg2) { body of function } to this code: function checkRange(argument) { some checking } function(arg1,…
saha
  • 23
  • 5