Skip to content

Commit

Permalink
prepare deprecating support for @ commands, see #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Icemic committed Mar 11, 2017
1 parent a7f25f1 commit 4c62264
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions actions/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

module.exports = {
StoryLine_formatA(head, command, content, foot) {
console.warn('[Deprecated] Command beginning with `@` will no longer be supported.')
var content = content.parse();
return {
type: 'content',
Expand All @@ -34,6 +35,7 @@ module.exports = {
}
},
StoryLine_formatC(head, command, foot) {
console.warn('[Deprecated] Command beginning with `@` will no longer be supported.')
return {
type: 'content',
command: command.parse(),
Expand Down
6 changes: 3 additions & 3 deletions ohm/bks.ohm.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ BKS {
comment_multi = (~("*/") any)+
StoryLine
= "@" command content ("\\r"|"\\n")? -- formatA
| "[" command content "]" -- formatB
| "@" command ("\\r"|"\\n")? -- formatC
= "[" command content "]" -- formatB
| "@" command content ("\\r"|"\\n"|end) -- formatA
| "@" command ("\\r"|"\\n"|end) -- formatC
| "[" command "]" -- formatD
| text -- formatE
Expand Down
38 changes: 19 additions & 19 deletions test/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Parser', () => {
});

it('parse parameter value of ascii string', () => {
expect(parse('@name param="string"'))
expect(parse('[name param="string"]'))
.to.eql([{
type: 'content',
command: 'name',
Expand All @@ -44,7 +44,7 @@ describe('Parser', () => {
}]);
});
it('parse parameter value of non-ascii string', () => {
expect(parse('@name param="中文测试,日本語の分析テスト" param2=\'中a文s\\测**|/试%……%\''))
expect(parse('[name param="中文测试,日本語の分析テスト" param2=\'中a文s\\测**|/试%……%\']'))
.to.eql([{
type: 'content',
command: 'name',
Expand All @@ -56,7 +56,7 @@ describe('Parser', () => {
}]);
});
it('parse parameter value of number', () => {
expect(parse('@name param1=123 param2=00123 param3=0x123 param4=-10 param5=+0x20 param6=10.02 param7=.4'))
expect(parse('[name param1=123 param2=00123 param3=0x123 param4=-10 param5=+0x20 param6=10.02 param7=.4]'))
.to.eql([{
type: 'content',
command: 'name',
Expand All @@ -73,7 +73,7 @@ describe('Parser', () => {
}]);
});
it('parse parameter value of boolean', () => {
expect(parse('@name param=true param2=false'))
expect(parse('[name param=true param2=false]'))
.to.eql([{
type: 'content',
command: 'name',
Expand All @@ -85,7 +85,7 @@ describe('Parser', () => {
}]);
});
it('parse parameter value of null', () => {
expect(parse('@name param=null param2=false'))
expect(parse('[name param=null param2=false]'))
.to.eql([{
type: 'content',
command: 'name',
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('Parser', () => {

it('parse multi lines', () => {
expect(parse(`
@name param=123
[name param=123]
[name flag]
`))
.to.eql([
Expand All @@ -136,13 +136,13 @@ describe('Parser', () => {
it('parse IF-ELSEIF-ELSE', () => {
expect(parse(`
#if x > 1
@name flagA
[name flagA]
#elseif y == 2
#elseif y <= 300
#else
@name flagB
[name flagB]
#end
@name flagC
[name flagC]
`)).to.eql([
{
type: 'logic', name: 'if',
Expand All @@ -162,11 +162,11 @@ describe('Parser', () => {
});
it('parse WHILE', () => {
expect(parse(`
@name flagA
[name flagA]
#while x > 1
@name flagB
[name flagB]
#end
@name flagC
[name flagC]
`)).to.eql([
{ type: 'content', command: 'name', flags: ['flagA'], params: {} },
{
Expand All @@ -186,11 +186,11 @@ describe('Parser', () => {
});
it('parse FOREACH', () => {
expect(parse(`
@name flagA
[name flagA]
#foreach child in children
@name flagB
[name flagB]
#end
@name flagC
[name flagC]
`)).to.eql([
{ type: 'content', command: 'name', flags: ['flagA'], params: {} },
{
Expand All @@ -204,11 +204,11 @@ describe('Parser', () => {
});
it('parse LET', () => {
expect(parse(`
@name flagA
[name flagA]
#let variable = "123"
#let variable2 = variable
#let variable3
@name flagB
[name flagB]
#variable4 = true
`)).to.eql([
{ type: 'content', command: 'name', flags: ['flagA'], params: {} },
Expand Down Expand Up @@ -242,9 +242,9 @@ describe('Parser', () => {
it('parse complex logic expression', () => {
expect(parse(`
#while x > 1 && ((x == 'test' || y >= 30) && a) || (b + 2) * -10
@name
[name]
这是一句话,哈哈~!
@name flagB
[name flagB]
Some words!
#end
`)).to.eql([
Expand Down

0 comments on commit 4c62264

Please sign in to comment.