Skip to content

Commit 04337ed

Browse files
author
ChenYong
committed
expose line info at error; workflow updates; alpha release
1 parent d119031 commit 04337ed

File tree

5 files changed

+85
-16
lines changed

5 files changed

+85
-16
lines changed

.github/workflows/npm-publish.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: npm publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
registry-url: https://registry.npmjs.org/
16+
17+
- run: yarn && yarn compile
18+
19+
- run: npm publish
20+
env:
21+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/upload.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Upload Assets
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
upload-assets:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Use Node.js
16+
uses: actions/setup-node@v1
17+
18+
- name: Get yarn cache
19+
id: yarn-cache
20+
run: echo "::set-output name=dir::$(yarn cache dir)"
21+
22+
- uses: actions/cache@v1
23+
with:
24+
path: ${{ steps.yarn-cache.outputs.dir }}
25+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-yarn-
28+
29+
- run: yarn && yarn release
30+
name: Build web assets
31+
32+
- name: Deploy to server
33+
id: deploy
34+
uses: Pendect/action-rsyncer@v1.1.0
35+
env:
36+
DEPLOY_KEY: ${{secrets.rsync_private_key}}
37+
with:
38+
flags: "-avzr --progress"
39+
options: ""
40+
ssh_options: ""
41+
src: "dist/*"
42+
dest: "rsync-user@fe.jimu.io:/web-assets/repo/${{ github.repository }}"
43+
44+
- name: Display status from deploy
45+
run: echo "${{ steps.deploy.outputs.status }}"

cirru/comma.cirru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
print (, a)
33
a
44
, b
5-
, c (, d)
5+
, c (, d)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cirru-parser",
3-
"version": "0.10.7",
3+
"version": "0.10.8-a1",
44
"description": "Cirru Parser in CoffeeScript",
55
"main": "./lib/parser.js",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
"release-html": "env=release cirruscript template.cirru",
1313
"up": "yarn release && cp -r cirru dist/ && tiye-up",
1414
"compile": "coffee -o lib/ -bc src/",
15-
"test": "cirru-script test.cirru"
15+
"test": "cirruscript test.cirru"
1616
},
1717
"author": "jiyinyiyong",
1818
"license": "MIT",

src/parser.coffee

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ exports.pare = (code, filename) ->
3535

3636
shorten res
3737

38+
prefixError = (state) ->
39+
"#{state.path or "FILE"}(#{state.y}:#{state.x})"
40+
3841
# eof
3942

4043
_escape_eof = (xs, buffer, state, code) ->
41-
throw new Error "EOF in escape state"
44+
throw new Error "#{prefixError(state)} EOF in escape state"
4245

4346
_string_eof = (xs, buffer, state, code) ->
44-
throw new Error "EOF in string state"
47+
throw new Error "#{prefixError(state)} EOF in string state"
4548

4649
_space_eof = (xs, buffer, state, code) ->
4750
xs
@@ -59,7 +62,7 @@ _indent_eof = (xs, buffer, state, code) ->
5962
# escape
6063

6164
_escape_newline = (xs, buffer, state, code) ->
62-
throw new Error 'newline while escape'
65+
throw new Error "#{prefixError(state)} newline while escape"
6366

6467
_escape_n = (xs, buffer, state, code) ->
6568
state.x += 1
@@ -87,7 +90,7 @@ _string_backslash = (xs, buffer, state, code) ->
8790
[xs, buffer, state, code[1..]]
8891

8992
_string_newline = (xs, buffer, state, code) ->
90-
throw new Error 'newline in a string'
93+
throw new Error "#{prefixError(state)} newline in a string"
9194

9295
_string_quote = (xs, buffer, state, code) ->
9396
state.name = 'token'
@@ -126,7 +129,7 @@ _space_close = (xs, buffer, state, code) ->
126129
state.nest -= 1
127130
state.level -= 1
128131
if state.nest < 0
129-
throw new Error 'close at space'
132+
throw new Error "#{prefixError(state)} close at space"
130133
state.x += 1
131134
[xs, buffer, state, code[1..]]
132135

@@ -173,7 +176,7 @@ _token_newline = (xs, buffer, state, code) ->
173176
[xs, buffer, state, code[1..]]
174177

175178
_token_open = (xs, buffer, state, code) ->
176-
throw new Error 'open parenthesis in token'
179+
throw new Error "#{prefixError(state)} open parenthesis in token"
177180

178181
_token_close = (xs, buffer, state, code) ->
179182
state.name = 'space'
@@ -207,12 +210,12 @@ _indent_newilne = (xs, buffer, state, code) ->
207210
[xs, buffer, state, code[1..]]
208211

209212
_indent_close = (xs, buffer, state, code) ->
210-
throw new Error 'close parenthesis at indent'
213+
throw new Error "#{prefixError(state)} close parenthesis at indent"
211214

212215
_indent_else = (xs, buffer, state, code) ->
213216
state.name = 'space'
214217
if (state.indented % 2) is 1
215-
throw new Error 'odd indentation'
218+
throw new Error "#{prefixError(state)} odd indentation"
216219
indented = state.indented / 2
217220
diff = indented - state.indent
218221

@@ -238,22 +241,22 @@ parse = (xs, buffer, state, code) ->
238241
when 'escape'
239242
if eof then _escape_eof args...
240243
else switch char
241-
when '\r' '\n' then _escape_newline args...
244+
when '\r', '\n' then _escape_newline args...
242245
when 'n' then _escape_n args...
243246
when 't' then _escape_t args...
244247
else _escape_else args...
245248
when 'string'
246249
if eof then _string_eof args...
247250
else switch char
248251
when '\\' then _string_backslash args...
249-
when '\r' '\n' then _string_newline args...
252+
when '\r', '\n' then _string_newline args...
250253
when '"' then _string_quote args...
251254
else _string_else args...
252255
when 'space'
253256
if eof then _space_eof args...
254257
else switch char
255258
when ' ' then _space_space args...
256-
when '\r' '\n' then _space_newline args...
259+
when '\r', '\n' then _space_newline args...
257260
when '(' then _space_open args...
258261
when ')' then _space_close args...
259262
when '"' then _space_quote args...
@@ -262,7 +265,7 @@ parse = (xs, buffer, state, code) ->
262265
if eof then _token_eof args...
263266
else switch char
264267
when ' ' then _token_space args...
265-
when '\r' '\n' then _token_newline args...
268+
when '\r', '\n' then _token_newline args...
266269
when '(' then _token_open args...
267270
when ')' then _token_close args...
268271
when '"' then _token_quote args...
@@ -271,6 +274,6 @@ parse = (xs, buffer, state, code) ->
271274
if eof then _indent_eof args...
272275
else switch char
273276
when ' ' then _indent_space args...
274-
when '\r' '\n' then _indent_newilne args...
277+
when '\r', '\n' then _indent_newilne args...
275278
when ')' then _indent_close args...
276279
else _indent_else args...

0 commit comments

Comments
 (0)