Skip to content

Commit

Permalink
expose line info at error; workflow updates; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYong committed Aug 19, 2020
1 parent d119031 commit 04337ed
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: npm publish

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- run: yarn && yarn compile

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
45 changes: 45 additions & 0 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Upload Assets

on:
pull_request: {}
push:
branches:
- master

jobs:
upload-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v1

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn && yarn release
name: Build web assets

- name: Deploy to server
id: deploy
uses: Pendect/action-rsyncer@v1.1.0
env:
DEPLOY_KEY: ${{secrets.rsync_private_key}}
with:
flags: "-avzr --progress"
options: ""
ssh_options: ""
src: "dist/*"
dest: "rsync-user@fe.jimu.io:/web-assets/repo/${{ github.repository }}"

- name: Display status from deploy
run: echo "${{ steps.deploy.outputs.status }}"
2 changes: 1 addition & 1 deletion cirru/comma.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
print (, a)
a
, b
, c (, d)
, c (, d)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cirru-parser",
"version": "0.10.7",
"version": "0.10.8-a1",
"description": "Cirru Parser in CoffeeScript",
"main": "./lib/parser.js",
"scripts": {
Expand All @@ -12,7 +12,7 @@
"release-html": "env=release cirruscript template.cirru",
"up": "yarn release && cp -r cirru dist/ && tiye-up",
"compile": "coffee -o lib/ -bc src/",
"test": "cirru-script test.cirru"
"test": "cirruscript test.cirru"
},
"author": "jiyinyiyong",
"license": "MIT",
Expand Down
29 changes: 16 additions & 13 deletions src/parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ exports.pare = (code, filename) ->

shorten res

prefixError = (state) ->
"#{state.path or "FILE"}(#{state.y}:#{state.x})"

# eof

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

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

_space_eof = (xs, buffer, state, code) ->
xs
Expand All @@ -59,7 +62,7 @@ _indent_eof = (xs, buffer, state, code) ->
# escape

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

_escape_n = (xs, buffer, state, code) ->
state.x += 1
Expand Down Expand Up @@ -87,7 +90,7 @@ _string_backslash = (xs, buffer, state, code) ->
[xs, buffer, state, code[1..]]

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

_string_quote = (xs, buffer, state, code) ->
state.name = 'token'
Expand Down Expand Up @@ -126,7 +129,7 @@ _space_close = (xs, buffer, state, code) ->
state.nest -= 1
state.level -= 1
if state.nest < 0
throw new Error 'close at space'
throw new Error "#{prefixError(state)} close at space"
state.x += 1
[xs, buffer, state, code[1..]]

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

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

_token_close = (xs, buffer, state, code) ->
state.name = 'space'
Expand Down Expand Up @@ -207,12 +210,12 @@ _indent_newilne = (xs, buffer, state, code) ->
[xs, buffer, state, code[1..]]

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

_indent_else = (xs, buffer, state, code) ->
state.name = 'space'
if (state.indented % 2) is 1
throw new Error 'odd indentation'
throw new Error "#{prefixError(state)} odd indentation"
indented = state.indented / 2
diff = indented - state.indent

Expand All @@ -238,22 +241,22 @@ parse = (xs, buffer, state, code) ->
when 'escape'
if eof then _escape_eof args...
else switch char
when '\r' '\n' then _escape_newline args...
when '\r', '\n' then _escape_newline args...
when 'n' then _escape_n args...
when 't' then _escape_t args...
else _escape_else args...
when 'string'
if eof then _string_eof args...
else switch char
when '\\' then _string_backslash args...
when '\r' '\n' then _string_newline args...
when '\r', '\n' then _string_newline args...
when '"' then _string_quote args...
else _string_else args...
when 'space'
if eof then _space_eof args...
else switch char
when ' ' then _space_space args...
when '\r' '\n' then _space_newline args...
when '\r', '\n' then _space_newline args...
when '(' then _space_open args...
when ')' then _space_close args...
when '"' then _space_quote args...
Expand All @@ -262,7 +265,7 @@ parse = (xs, buffer, state, code) ->
if eof then _token_eof args...
else switch char
when ' ' then _token_space args...
when '\r' '\n' then _token_newline args...
when '\r', '\n' then _token_newline args...
when '(' then _token_open args...
when ')' then _token_close args...
when '"' then _token_quote args...
Expand All @@ -271,6 +274,6 @@ parse = (xs, buffer, state, code) ->
if eof then _indent_eof args...
else switch char
when ' ' then _indent_space args...
when '\r' '\n' then _indent_newilne args...
when '\r', '\n' then _indent_newilne args...
when ')' then _indent_close args...
else _indent_else args...

0 comments on commit 04337ed

Please # to comment.