File tree 4 files changed +72
-14
lines changed
4 files changed +72
-14
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,6 @@ dmypy.json
127
127
128
128
# Pyre type checker
129
129
.pyre /
130
+
131
+ # Node
132
+ node_modules
Original file line number Diff line number Diff line change @@ -2960,7 +2960,9 @@ class InteractiveParser {
2960
2960
accepts ( ) {
2961
2961
let new_cursor ;
2962
2962
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 ] ;
2964
2966
if ( isupper ( t ) ) {
2965
2967
// is terminal?
2966
2968
new_cursor = copy ( this ) ;
@@ -3757,10 +3759,7 @@ class Lark extends Serialize {
3757
3759
3758
3760
*/
3759
3761
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 ) ;
3764
3763
}
3765
3764
3766
3765
/**
Original file line number Diff line number Diff line change 1
1
const { TestTrees} = require ( "./test_trees.js" ) ;
2
+ const { TestInteractive} = require ( "./test_interactive.js" ) ;
2
3
3
4
function run_test_class ( cls ) {
4
- describe ( cls . constructor . name , function ( ) {
5
+ describe ( cls . constructor . name , function ( ) {
5
6
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
+ } ) ;
13
16
}
14
17
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