fkling / fkling/astexplorer

Integration server side parser ?

Open
#222 8 comments 3 reactions 0 assignees View on GitHub
needs discussion
Dominant language
JavaScript
Stars
6.5k
Forks
772
PR merge metrics
No merged PRs in 30d

Description

For example, I use [PHP-Parser on PHP](https://github.com/nikic/PHP-Parser/) and create [astexplorer from ajax and php backend](http://php-ast.herokuapp.com/out/)

```js
// php parser
import defaultParserInterface from '../utils/defaultParserInterface';

const ID = 'php-ast-parser';

export default {
...defaultParserInterface,
id: ID,
displayName: ID,
version: '7.1',
_ignoredProperties: new Set([]),
locationProps: new Set(['attributes']),
nodeToRange({attributes} = {}) {
if (attributes) {
return [attributes.startFilePos, attributes.endFilePos+1];
}
},
getNodeName(node) {
return node.nodeType;
},
loadParser(callback) {
callback();
},
opensByDefault(node, key) {
return key === 'stmts';
},
parse(a, code) {
return fetch('/index.php',{
method: 'post',
body: code,
})
.then(function(response) {
return response.json();
});
},
};
```

how to integrate server side parse in [astexplorer.net](https://astexplorer.net)?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.