Skip to content

Commit 7e98d5e

Browse files
committed
update
1 parent e89de54 commit 7e98d5e

File tree

3 files changed

+12
-56
lines changed

3 files changed

+12
-56
lines changed

csbuild/ecs_bootstrap.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"Name": "ecs_bootstrap",
44
"Info": "Extended CovScript(ECS Lang) Bootstrap",
55
"Author": "Michael Lee",
6-
"Version": "1.5.1",
6+
"Version": "1.5.2",
77
"Target": "imports/ecs_bootstrap.csp",
88
"Dependencies": [
99
"parsergen",

imports/ecs_bootstrap.csp

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Bootstrap of Extended Covariant Script Generator v1.4.3
1+
# Bootstrap of Extended Covariant Script Generator v1.5.2
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ package ecs_bootstrap
2323
import parsergen, ecs_parser, ecs_generator, codec, regex
2424
import sdk_extension as sdk
2525

26-
var wrapper_ver = "1.5.1"
26+
var wrapper_ver = "1.5.2"
2727

2828
function show_version_simple()
2929
@begin
@@ -36,61 +36,29 @@ function show_version_simple()
3636
end
3737

3838
class repl_instance
39-
var syntax_stages = {"ignore", "nlook", "repeat", "optional", "cond_or"}.to_hash_set()
4039
var codegen = new ecs_generator.generator
41-
var parser = new parsergen.repl_parser_type
40+
var parser = new parsergen.partial_parser_type
4241
var unicode_cvt = null
43-
var repl_impl = null
4442
var code_buff = new array
45-
var stages = new array
43+
var repl_impl = null
4644
var silent = false
47-
function find_first_stage(parser)
48-
foreach it in parser.stack
49-
link name = it.product.root
50-
if !syntax_stages.exist(name)
51-
return name
52-
end
53-
end
54-
end
55-
function repl_hook(parser)
56-
if !parser.eof()
57-
return parsergen.parse_state.accept
58-
end
59-
if stages.size > 0
60-
var tokens = null
61-
loop
62-
tokens = this.readline()
63-
until tokens != null
64-
foreach it in tokens do parser.lex.push_back(it)
65-
end
66-
return parsergen.parse_state.accept
67-
end
6845
function on_eof_hook(parser)
69-
stages.push_front(find_first_stage(parser))
7046
var tokens = null
7147
loop
72-
tokens = this.readline()
48+
tokens = this.readline("..> ")
7349
until tokens != null
7450
foreach it in tokens do parser.lex.push_back(it)
7551
return true
7652
end
77-
function accept_hook(parser)
78-
if !stages.empty() && find_first_stage(parser) == stages.front
79-
stages.pop_front()
80-
end
81-
end
8253
function initialize()
83-
ecs_parser.grammar.stx.stmts = ecs_parser.grammar.stx.stmts_repl
84-
ecs_parser.repl_hook = repl_hook
8554
parser.on_eof_hook = on_eof_hook
86-
parser.accept_hook = accept_hook
55+
codegen.code_buff := code_buff
8756
codegen.file_name = "<REPL_ENV>"
8857
codegen.minmal = true
8958
end
90-
function readline()
59+
function readline(prompt)
9160
if !silent
92-
foreach i in range(stages.size*2) do system.out.print(".")
93-
system.out.print("> ")
61+
system.out.print(prompt)
9462
end
9563
var line = repl_impl.readline()
9664
code_buff.push_back(line)
@@ -106,10 +74,10 @@ class repl_instance
10674
else
10775
lexer = new parsergen.lexer_type
10876
end
77+
lexer.pos[1] = code_buff.size - 1
10978
var tokens = lexer.run(ecs_parser.grammar.lex, line)
11079
if !lexer.error_log.empty()
11180
parsergen.print_error("<REPL_ENV>", code_buff, lexer.error_log)
112-
code_buff = new array
11381
return new array
11482
else
11583
return tokens
@@ -128,12 +96,11 @@ class repl_instance
12896
loop
12997
var tokens = null
13098
loop
131-
tokens = this.readline()
99+
tokens = this.readline("> ")
132100
until tokens != null
133101
if parser.run(ecs_parser.grammar.stx, tokens)
134102
var ast = parser.production()
135103
if ast != null
136-
codegen.code_buff = code_buff
137104
var code = codegen.repl_run(ast)
138105
if code != null
139106
code = code.split({'\n'})
@@ -145,17 +112,13 @@ class repl_instance
145112
end
146113
catch e
147114
system.out.println(e.what)
148-
stages = new array
149115
repl_impl.reset()
150116
end
151117
end
152-
code_buff = new array
153118
end
154119
else
155120
var err = parser.get_log(0)
156121
parsergen.print_error("<REPL_ENV>", {code_buff..., ""}, err)
157-
code_buff = new array
158-
stages = new array
159122
repl_impl.reset()
160123
end
161124
end

imports/ecs_parser.csp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ function get_lexical(reg_builder)
4343
@end
4444
end
4545

46-
var repl_hook = null
47-
4846
@begin
4947
var covscript_syntax = {
5048
# Beginning of Parsing
@@ -61,13 +59,9 @@ var covscript_syntax = {
6159
{syntax.term(";")}
6260
)},
6361
# Bootstrap
64-
"stmts" : null,
65-
"stmts_norm" : {
62+
"stmts" : {
6663
syntax.repeat(syntax.nlook(syntax.ref("endblock")), syntax.ref("statement"), syntax.repeat(syntax.token("endl")))
6764
},
68-
"stmts_repl" : {
69-
syntax.repeat(syntax.nlook(syntax.ref("endblock")), syntax.ref("statement"), syntax.repeat(syntax.token("endl")), syntax.hook([](obj)->repl_hook(obj)))
70-
},
7165
"decl-stmts" : {
7266
syntax.repeat(syntax.ref("declaration"), syntax.repeat(syntax.token("endl")))
7367
},
@@ -353,4 +347,3 @@ var grammar = new parsergen.grammar
353347
grammar.ext = ".*\\.(csp|csc|ecs|ecsx)"
354348
grammar.lex = get_lexical(regex.build)
355349
grammar.stx := covscript_syntax
356-
covscript_syntax.stmts = covscript_syntax.stmts_norm

0 commit comments

Comments
 (0)