File tree Expand file tree Collapse file tree 7 files changed +86
-6
lines changed
Expand file tree Collapse file tree 7 files changed +86
-6
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ The AST explorer provides following code parsers:
6969 - [ regexp-tree] [ ]
7070 - [ regexpp] [ ]
7171 - [ regjsparser] [ ]
72+ - Protocol Buffers:
73+ - [ pbkit] [ ]
7274- Scala
7375 - [ Scalameta] [ ]
7476- Solidity:
@@ -150,6 +152,7 @@ are included so you can prototype your own plugins:
150152[ luaparse ] : https://oxyc.github.io/luaparse/
151153[ meriyah ] : https://github.com/meriyah/meriyah/
152154[ parse5 ] : https://github.com/inikulin/parse5
155+ [ pbkit ] : https://github.com/riiid/pbkit
153156[ postcss-safe-parser ] : https://github.com/postcss/postcss-safe-parser
154157[ postcss-scss ] : https://github.com/postcss/postcss-scss
155158[ postcss ] : https://github.com/postcss/postcss
Original file line number Diff line number Diff line change 115115 "meriyah" : " ^1.9.12" ,
116116 "parse5" : " ^6.0.0" ,
117117 "parse5-htmlparser2-tree-adapter" : " ^6.0.0" ,
118+ "pbkit" : " ^0.0.12" ,
118119 "php-parser" : " ^3.0.0" ,
119120 "postcss" : " ^7.0.27" ,
120121 "postcss-less" : " ^3.1.2" ,
Original file line number Diff line number Diff line change 1+ syntax = "proto3";
2+ package tutorial;
3+
4+ import "google/protobuf/timestamp.proto";
5+
6+ option go_package = "github.com/protocolbuffers/protobuf/examples/go/tutorialpb";
7+
8+ message Person {
9+ string name = 1;
10+ int32 id = 2; // Unique ID number for this person.
11+ string email = 3;
12+
13+ enum PhoneType {
14+ MOBILE = 0;
15+ HOME = 1;
16+ WORK = 2;
17+ }
18+
19+ message PhoneNumber {
20+ string number = 1;
21+ PhoneType type = 2;
22+ }
23+
24+ repeated PhoneNumber phones = 4;
25+
26+ google.protobuf.Timestamp last_updated = 5;
27+ }
28+
29+ // Our address book file is just one of these.
30+ message AddressBook {
31+ repeated Person people = 1;
32+ }
Original file line number Diff line number Diff line change 1+ import 'codemirror/mode/protobuf/protobuf' ;
2+
3+ export const id = 'protobuf' ;
4+ export const displayName = 'Protocol Buffers' ;
5+ export const mimeTypes = [ 'text/x-protobuf' ] ;
6+ export const fileExtension = 'proto' ;
Original file line number Diff line number Diff line change 1+ import defaultParserInterface from '../utils/defaultParserInterface' ;
2+ import pkg from 'pbkit/package.json' ;
3+
4+ const ID = 'pbkit' ;
5+
6+ export default {
7+ ...defaultParserInterface ,
8+ id : ID ,
9+ displayName : ID ,
10+ version : pkg . version ,
11+ homepage : 'https://github.com/riiid/pbkit' ,
12+ locationProps : new Set ( [ 'start' , 'end' ] ) ,
13+ typeProps : new Set ( [ 'type' ] ) ,
14+
15+ loadParser ( callback ) {
16+ require ( [ 'pbkit/core/parser/proto' ] , callback ) ;
17+ } ,
18+
19+ parse ( parser , code ) {
20+ return parser . parse ( code ) . ast ;
21+ } ,
22+
23+ nodeToRange ( node ) {
24+ const { start, end } = node ;
25+ return [ start , end ] ;
26+ } ,
27+
28+ opensByDefault ( node , key ) {
29+ if ( key === 'statements' ) {
30+ return true ;
31+ }
32+ } ,
33+ } ;
Original file line number Diff line number Diff line change @@ -43,11 +43,11 @@ const plugins = [
4343 // Shim ESLint stuff that's only relevant for Node.js
4444 new webpack . NormalModuleReplacementPlugin (
4545 / c l i - e n g i n e / ,
46- 'node-libs-browser/mock/empty'
46+ 'node-libs-browser/mock/empty' ,
4747 ) ,
4848 new webpack . NormalModuleReplacementPlugin (
4949 / l o a d - r u l e s / ,
50- __dirname + '/src/parsers/js/transformers/eslint1/loadRulesShim.js'
50+ __dirname + '/src/parsers/js/transformers/eslint1/loadRulesShim.js' ,
5151 ) ,
5252
5353 // There seems to be a problem with webpack loading an index.js file that
@@ -60,15 +60,15 @@ const plugins = [
6060 if ( / c s s - t r e e / . test ( module . context ) ) {
6161 module . request += '/index.js' ;
6262 }
63- }
63+ } ,
6464 ) ,
6565
6666 // More shims
6767
6868 // Doesn't look like jest-validate is useful in our case (prettier uses it)
6969 new webpack . NormalModuleReplacementPlugin (
7070 / j e s t - v a l i d a t e / ,
71- __dirname + '/src/shims/jest-validate.js'
71+ __dirname + '/src/shims/jest-validate.js' ,
7272 ) ,
7373
7474 // Hack to disable Webpack dynamic requires in ESLint, so we don't end up
@@ -94,7 +94,7 @@ const plugins = [
9494 new webpack . ProgressPlugin ( {
9595 modules : false ,
9696 activeModules : false ,
97- profile : false
97+ profile : false ,
9898 } ) ,
9999] ;
100100
@@ -270,5 +270,5 @@ module.exports = Object.assign({
270270 {
271271 devtool : 'eval' ,
272272 } :
273- { }
273+ { } ,
274274) ;
Original file line number Diff line number Diff line change @@ -8445,6 +8445,11 @@ pbkdf2@^3.0.3:
84458445 safe-buffer "^5.0.1"
84468446 sha.js "^2.4.8"
84478447
8448+ pbkit@^0.0.12 :
8449+ version "0.0.12"
8450+ resolved "https://registry.yarnpkg.com/pbkit/-/pbkit-0.0.12.tgz#f67a307867763da732f38198a53034342373d62d"
8451+ integrity sha512-NtHgxsdLpxwXyKWeeObkFbVLPQWoigyQfHJVZZJVI2h2pLC7wM39mbMzT0l89MPjB7Z7QTKzzVhtzMG9zWC2ug==
8452+
84488453php-parser@^3.0.0 :
84498454 version "3.0.0"
84508455 resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.0.0.tgz#7e0abef4941cabbf10f25f1445bca0f758f5102f"
You can’t perform that action at this time.
0 commit comments