Get started with opal-parser CDN

MIT licensed

Opal Parser is a library used for parsing and transforming Ruby code into equivalent JS code.

Tags:
  • opal
  • opal-parser
  • opal.js
  • opalrb
  • ruby
  • compiler
  • javascript
  • language

Stable version

Copied!

How to start using opal-parser CDN


// Include Opal Parser from the CDN
const OpalParser = require('opal-parser/dist/opal-parser.min.js');

// Opal code to be parsed
const opalCode = `
  (defn add 2 2)
  (add)
`;

// Parse the Opal code
OpalParser.parse(opalCode, (err, ast) => {
  if (err) {
    console.error('Error parsing Opal code:', err);
    return;
  }

  // Process the Abstract Syntax Tree (AST)
  // ...

  console.log('Parsed Opal code:', ast);
});
Copied!
Copied!

All versions