allang-compiler-base 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/base/log.ts +3 -3
- package/src/core/parser/grammar.ts +8 -6
package/package.json
CHANGED
package/src/base/log.ts
CHANGED
|
@@ -12,20 +12,21 @@ interface tools{
|
|
|
12
12
|
remove():void
|
|
13
13
|
get():token[]
|
|
14
14
|
}
|
|
15
|
-
function create_match(func:(tool:tools)=>boolean,error:(log:log)=>void):{func:(tool:tools)=>boolean,
|
|
16
|
-
error:(log:log)=>void}{
|
|
15
|
+
function create_match(func:(tool:tools)=>boolean,error:(log:log)=>void,to:()=>Tree):{func:(tool:tools)=>boolean,
|
|
16
|
+
error:(log:log)=>void,to:()=>Tree}{
|
|
17
17
|
return {
|
|
18
18
|
func:func,
|
|
19
|
+
to:to,
|
|
19
20
|
error:error
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
function root_match(tool:tools,log:log,parser:(
|
|
23
|
-
,error:(log:log)=>void}[]):Tree{
|
|
24
|
-
let matches:
|
|
23
|
+
function root_match(tool:tools,log:log,parser:(child:Tree[])=>Tree,...match:{func:((tool:tools)=>boolean)
|
|
24
|
+
,error:(log:log)=>void,to:()=>Tree}[]):Tree{
|
|
25
|
+
let matches:Tree[]=[]
|
|
25
26
|
for(let i=0;i<match.length;i++){
|
|
26
27
|
if(!match[i].func(tool))match[i].error(log)
|
|
27
28
|
else{
|
|
28
|
-
matches.push(
|
|
29
|
+
matches.push(match[i].to())
|
|
29
30
|
tool.flush()
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -45,5 +46,6 @@ function list_match(tool:tools,log:log,parser:(token:token[][])=>Tree,v?:(log:lo
|
|
|
45
46
|
return parser(matches)
|
|
46
47
|
}
|
|
47
48
|
class Tree{
|
|
49
|
+
type:number
|
|
48
50
|
}
|
|
49
51
|
export {tools,Tree,list_match,root_match,create_match}
|