You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import parse from './parse/index.js';
|
|
|
|
|
import validate from './validate/index.js';
|
|
|
|
|
import generate from './generate/index.js';
|
|
|
|
|
|
|
|
|
|
export function compile ( source, options = {} ) {
|
|
|
|
|
const parsed = parse( source, options );
|
|
|
|
|
|
|
|
|
|
if ( !options.onwarn ) {
|
|
|
|
|
options.onwarn = warning => {
|
|
|
|
|
if ( warning.loc ) {
|
|
|
|
|
console.warn( `(${warning.loc.line}:${warning.loc.column}) – ${warning.message}` ); // eslint-disable-line no-console
|
|
|
|
|
} else {
|
|
|
|
|
console.warn( warning.message ); // eslint-disable-line no-console
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { names } = validate( parsed, source, options );
|
|
|
|
|
|
|
|
|
|
return generate( parsed, source, options, names );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { parse, validate };
|