File tree Expand file tree Collapse file tree 4 files changed +72
-14
lines changed Expand file tree Collapse file tree 4 files changed +72
-14
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,6 @@ dmypy.json
127127
128128# Pyre type checker
129129.pyre /
130+
131+ # Node
132+ node_modules
Original file line number Diff line number Diff line change @@ -2960,7 +2960,9 @@ class InteractiveParser {
29602960 accepts ( ) {
29612961 let new_cursor ;
29622962 let accepts = new Set ( ) ;
2963- for ( const t of this . choices ( ) ) {
2963+ const choices = this . choices ( ) ;
2964+ for ( const key in choices ) {
2965+ const t = choices [ key ] ;
29642966 if ( isupper ( t ) ) {
29652967 // is terminal?
29662968 new_cursor = copy ( this ) ;
@@ -3757,10 +3759,7 @@ class Lark extends Serialize {
37573759
37583760 */
37593761 parse_interactive ( text = null , start = null ) {
3760- return this . parser . parse_interactive ( {
3761- unknown_param_0 : text ,
3762- start : start ,
3763- } ) ;
3762+ return this . parser . parse_interactive ( text , start ) ;
37643763 }
37653764
37663765 /**
Original file line number Diff line number Diff line change 11const { TestTrees} = require ( "./test_trees.js" ) ;
2+ const { TestInteractive} = require ( "./test_interactive.js" ) ;
23
34function run_test_class ( cls ) {
4- describe ( cls . constructor . name , function ( ) {
5+ describe ( cls . constructor . name , function ( ) {
56
6- let test = new cls ( ) ;
7- test . setUp ( ) ;
8- let test_names = Object . getOwnPropertyNames ( cls . prototype ) . filter ( ( prop ) => prop . startsWith ( "test_" ) )
9- for ( const name of test_names ) {
10- it ( name , ( ) => { test [ name ] ( ) } )
11- }
12- } ) ;
7+ let test = new cls ( ) ;
8+ if ( test . setUp ) {
9+ test . setUp ( ) ;
10+ }
11+ let test_names = Object . getOwnPropertyNames ( cls . prototype ) . filter ( ( prop ) => prop . startsWith ( "test_" ) )
12+ for ( const name of test_names ) {
13+ it ( name , ( ) => { test [ name ] ( ) } )
14+ }
15+ } ) ;
1316}
1417
15- run_test_class ( TestTrees ) ;
18+ run_test_class ( TestTrees ) ;
19+ run_test_class ( TestInteractive ) ;
Original file line number Diff line number Diff line change 1+ const _ = require ( "lodash" ) ;
2+ const lark = require ( "../larkjs/lark.js" ) ;
3+ const assert = require ( 'assert' ) ;
4+
5+ const {
6+ InteractiveParser,
7+ } = lark ;
8+
9+ //
10+ // Test Interactive
11+ //
12+
13+ class TestCase {
14+ assertOk ( a ) {
15+ assert ( ! ! a ) ; // assert that the value is truthy
16+ }
17+ }
18+
19+ class TestInteractive extends TestCase {
20+ test_it_parses_interactively ( ) {
21+ const mockParser = { } ;
22+ const mockParserState = {
23+ position : 30 ,
24+ parse_conf : {
25+ parse_table : {
26+ states : {
27+ 30 : {
28+
29+ "ESCAPED_STRING" : [
30+ {
31+ "name" : "Shift"
32+ } ,
33+ 8
34+ ] ,
35+ "string" : [
36+ {
37+ "name" : "Shift"
38+ } ,
39+ 7
40+ ] ,
41+ } ,
42+ }
43+ }
44+ } } ;
45+ const mockLexerThread = { } ;
46+ const interactiveParser = new InteractiveParser ( mockParser , mockParserState , mockLexerThread ) ;
47+ this . assertOk ( interactiveParser . accepts ( ) ) ;
48+ }
49+ }
50+
51+ module . exports = { TestInteractive } ;
52+
You can’t perform that action at this time.
0 commit comments