Skip to content

Commit 2b4ad63

Browse files
author
Pavel Petroshenko
authored
Merge pull request #29 from electricimp/develop
Comments at the end of line of any statement
2 parents 618bb5e + 6773c38 commit 2b4ad63

18 files changed

+388
-81
lines changed

Diff for: LICENSE

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2016 Electric Imp
3+
Copyright 2016-2017 Electric Imp
4+
5+
SPDX-License-Identifier: MIT
46

57
Permission is hereby granted, free of charge, to any person obtaining a copy
68
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +11,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
911
copies of the Software, and to permit persons to whom the Software is
1012
furnished to do so, subject to the following conditions:
1113

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
1416

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Use this directive to includes local files, external sources, or macros.
170170

171171
#### Single Line Comments
172172

173-
Any text after `include`, and between `//` and the end of the line, will be ignored by Builder and will not appear in the result output.
173+
Any text after any _Builder_ expression statement, starting with `//` and extending to the end of the line, will be ignored by _Builder_ and will not appear in the result output.
174174

175175
<pre>
176176
<b>@include</b> "https://example.com/file.ext" // Need update to file2.ext

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Builder",
3-
"version": "2.2.2",
3+
"version": "2.2.4",
44
"description": "Builder Language Implementation",
55
"main": "src/index.js",
66
"bin": {

Diff for: spec/Machine/comments.spec.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
25+
'use strict';
26+
27+
require('jasmine-expect');
28+
const init = require('./init')('main');
29+
const jasmineDiffMatchers = require('jasmine-diff-matchers');
30+
31+
describe('Machine', () => {
32+
let machine;
33+
34+
beforeEach(() => {
35+
machine = init.createMachine();
36+
// show string diffs
37+
jasmine.addMatchers(jasmineDiffMatchers.diffChars);
38+
});
39+
40+
it('should handle comments in include corectly', () => {
41+
const ans = 'a.builder\n';
42+
expect(machine.execute(`@include "${__dirname}/../fixtures/" + "lib/a.builder" // comment`)).toEqual(ans);
43+
expect(machine.execute(`@include "${__dirname}/../fixtures//" + '//lib/a.builder' // comment`)).toEqual(ans);
44+
expect(machine.execute(`@include "${__dirname}/../fixtures/lib/a.builder"//comment+/comment+"some more comment"`)).toEqual(ans);
45+
expect(machine.execute(`@include "${__dirname}/../fixtures/" + 'lib/a.builder' // comment with //`)).toEqual(ans);
46+
expect(machine.execute(`@include "${__dirname}/../fixtures/lib/a.builder" // comment with some expr (1 | 0)`)).toEqual(ans);
47+
expect(machine.execute(`@include "${__dirname}/../fixtures/" + 'lib/a.builder' // comment with " ' ( ] {`)).toEqual(ans);
48+
});
49+
50+
it('should handle @while corectly #1', () => {
51+
const res = machine.execute(
52+
`
53+
@if METER_PROTOCOL_REV == 2.02 // comment 1
54+
@set PERIODIC_DATA_PERIOD = 200 // comment 2
55+
@else // comment 3
56+
@set METER_PROTOCOL_REV 1.07 // comment 4
57+
@set PERIODIC_DATA_PERIOD = 1
58+
@end
59+
@{PERIODIC_DATA_PERIOD} @{METER_PROTOCOL_REV}
60+
`
61+
);
62+
63+
expect(res).diffChars(
64+
`
65+
1 1.07
66+
`
67+
);
68+
});
69+
70+
});

Diff for: spec/Machine/include-comments.spec.js

-26
This file was deleted.

Diff for: src/AstParser.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

@@ -111,11 +131,12 @@ class AstParser {
111131
arg = matches[2].trim();
112132
token.args = [];
113133

134+
// remove single line comments from arg
135+
arg = decomment.text(arg);
136+
114137
switch (type) {
115138

116139
case 'include':
117-
// remove single line comments from arg
118-
arg = decomment.text(arg);
119140
// detect "once" flag
120141
if (/^once\b/.test(arg)) {
121142
token.args.push('once');

Diff for: src/Expression.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
/**
626
* Supported syntax:

Diff for: src/FileCache.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

Diff for: src/Filters/AbstractFilter.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

Diff for: src/Filters/Base64Filter.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

Diff for: src/Filters/EscapeFilter.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

Diff for: src/Machine.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2016-2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2016-2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
'use strict';
626

0 commit comments

Comments
 (0)