Oddo Language Package
npm install @oddo/langA high-performance parser and compiler for the Oddo language built with Chevrotain.
``bash`
npm install @oddo/lang
You'll also need Babel packages for code generation:
`bash`
npm install @babel/generator @babel/traverse @babel/types
- Complete Oddo language support
- Brace-based blocks (JavaScript-style)
- JSX syntax
- Modifiers (@state, @computed, @effect, @mutate)
- All JavaScript operators with correct precedence
- Arrow functions
- Arrays, objects, and all data types
`javascript
import { parseOddo, parseOddoExpression } from '@oddo/lang';
// Parse a full program
const ast = parseOddo(
x = 10
y = 20
return x + y);
// Parse an expression
const exprAst = parseOddoExpression('1 + 2 * 3');
`
`javascript
import { compileOddoToJS } from '@oddo/lang';
const jsCode = compileOddoToJS(
Counter = () => {
@state count = 0
@mutate increment = () => {
count := count + 1
}
return
}, { runtimeLibrary: '@oddo/ui' });`
`javascript
import { highlightOddo, getHighlightingCSS } from '@oddo/lang';
// Get CSS for highlighting
const css = getHighlightingCSS();
// Highlight code
const html = highlightOddo('@state count = 0');
``
MIT