Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9a362c

Browse files
committed
some fixes, still bugs
1 parentfbc69c8 commitd9a362c

File tree

3 files changed

+68
-31
lines changed

3 files changed

+68
-31
lines changed

‎iox.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node run.js

‎iox.ls

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,63 @@ rl = readline.createInterface do
88
isDigit = (n)->
99
returnn >='0' &&n <='9'
1010

11-
put = (needle,haystack,ins)->
12-
13-
1411
classState
15-
chunk:''
12+
line:''
1613
ins:0
1714
depth:0
18-
code:''
15+
chunk:''
1916
wrap:false
2017
chain:''
21-
putraw: (tk)->
18+
pending: []
19+
put: (tk,chain)->
2220
#if @wrap
23-
# @chunk = tk + '(' + @chunk + ')'
21+
# @line = tk + '(' + @line + ')'
2422
# @wrap = false
2523
#else
26-
@chunk = @chunk.substr(0,@ins) +tk + @chunk.substr(@ins)
24+
if @chain
25+
@line = @line.substr(0,@ins) + @chain + @line.substr(@ins)
26+
@ins += @chain.length
27+
@chain =''
28+
@line = @line.substr(0,@ins) +tk + @line.substr(@ins)
2729
@ins +=tk.length
30+
@chain =chain
2831
@depth++
29-
put: (tk)->
32+
putfunc: (tk)->
3033
if @wrap
31-
@chunk =tk +'(' + @chunk +')'
34+
@line =tk +'(' + @line +')'
3235
@wrap =false
3336
else
3437
if @chain
35-
@chunk = @chunk.substr(0,@ins) + @chain + @chunk.substr(@ins)
38+
@line = @line.substr(0,@ins) + @chain + @line.substr(@ins)
3639
@ins += @chain.length
3740
@chain =''
38-
@chunk = @chunk.substr(0,@ins) +tk +"()" + @chunk.substr(@ins)
41+
@line = @line.substr(0,@ins) +tk +"()" + @line.substr(@ins)
3942
@ins +=tk.length +1
4043
@depth++
44+
pend: ->
45+
if @line
46+
@pending.unshift(@line +';')
47+
@line =''
48+
@ins =0
49+
@depth =0
50+
@chain =''
51+
@wrap =false
4152
push: ->
42-
if @chunk
43-
console.log @chunk+';'
44-
@code += @chunk +';\n';
45-
@chunk =''
53+
if @line
54+
console.log @line+';'
55+
@chunk += @line +';\n'
56+
@line =''
57+
if @pending
58+
forlinein @pending
59+
console.logline
60+
#console.log @pending.join('\n')
61+
@chunk += @pending.join('\n')
62+
@pending = []
4663
@ins =0
4764
@depth =0
65+
@chain =''
66+
@wrap =false
4867

49-
code =''
5068
iter = (cb)->
5169
line <-rl.question'iox> '
5270
tokens =line.split(' ')
@@ -58,43 +76,59 @@ iter = (cb)->
5876
state =new State()
5977

6078
i =rtokens.length-1
61-
fortkinrtokens
79+
forifrom0tortokens.length-1
80+
tk =rtokens[i]
6281

82+
left =void
6383
try
64-
left =rtokens[i-1]
84+
left =rtokens[i+1]
6585
ifleft[left.length-1]==','
6686
# combine
6787
void
6888

69-
console.logstate.chunk
7089
tk0 =tk[0]
90+
tke =tk[tk.length-1]
7191
iftk0 =='$'
72-
ifstate.depth
73-
state.putraw(tk.substr(1))
74-
state.chain =' = '
75-
else
76-
state.putraw(tk.substr(1))
92+
#if state.depth
93+
state.put(tk.substr(1),' = ')
94+
#else
95+
# state.put(tk.substr(1))
7796
elseif isDigit(tk0)
7897
state.put(tk)
98+
state.pend()
99+
elseiftk0 =='\\'
100+
state.put("'" +tk.substr(1) +"'")
101+
elseiftke =='"'
102+
void
103+
#t = tk
104+
#s = ''
105+
#until t[0]=='"'
106+
# s += t
107+
# i += 1
108+
# t = rtokens[i]
109+
#state.put(tk)
79110
elseiftk0 =='['
80111
# parse array/range
81-
state.put(tk)
112+
void
82113
elseiftk0 =='('
83114
# parse range
84115
void
85116
elseiftk0 =='{'
86117
# parse dict
87-
state.put(tk)
118+
void
88119
elseiftk0 =='-'
89120
# flag
90121
void
91122
elseiftk0 =='+'
92123
# flag
93124
void
94-
else# function?
95-
state.put(tk)
96-
97-
i--
125+
elseiftk0 ==';'
126+
state.pend()
127+
else# function
128+
iftk=='out'
129+
state.putfunc('console.log')
130+
else
131+
state.putfunc(tk)
98132

99133
state.push()
100134
returncb!

‎iox.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
node run.js

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp