Skip to content

Commit

Permalink
Release 0.5.4 (and lint)
Browse files Browse the repository at this point in the history
  • Loading branch information
japhib committed Jul 14, 2024
1 parent 40ba6b7 commit a4149e0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.5.4 (7/14/2023)

- Add support for one-line `while` loop construct ([#11](https://github.com/japhib/pico8-ls/issues/11))
- Add support for new conditional syntax `if ... do ... end` ([#57](https://github.com/japhib/pico8-ls/issues/57))
- Fix changelog link ([#52](https://github.com/japhib/pico8-ls/pull/52))

## 0.5.3 (11/10/2023)

- Add support for code folding using `#region` comments ([#49](https://github.com/japhib/pico8-ls/pull/49)) - thanks [@TheCyberRonin](https://github.com/TheCyberRonin)!
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "JanPaul Bergeson",
"publisher": "PollywogGames",
"license": "MIT",
"version": "0.5.3",
"version": "0.5.4",
"repository": {
"type": "git",
"url": "https://github.com/japhib/pico8-ls"
Expand Down
4 changes: 2 additions & 2 deletions server/src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,14 @@ export default class Parser {
// regular while statement with `do` ... `end`
// (we already consumed the `do`)
body = this.parseWhileStatementBody(flowContext);
this.lexer.expect('end');
this.lexer.expect('end');
} else if (canBeOneLiner) {
// Handle special one-line while statement
this.lexer.withSignificantNewline(() => {
body = this.parseWhileStatementBody(flowContext);
});
} else {
errors.raiseErrForToken(this.token!, errMessages.expected, 'do', this.token!.value);
errors.raiseErrForToken(this.token, errMessages.expected, 'do', this.token.value);
}

return this.finishNode(AST.whileStatement(condition, body!));
Expand Down
36 changes: 27 additions & 9 deletions server/src/parser/test/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { strictEqual as eq } from 'assert';
import { bounds, deepEquals, deepEqualsAST, getTestFileContents, MockFileResolver, parse } from './test-utils';
import { inspect } from 'util';

describe('Parser', () => {
it('parses basic assignment statement', () => {
Expand Down Expand Up @@ -418,9 +417,28 @@ end
});

it('parses a regular while statement', () => {
const { errors, block: { body } } = parse('while a < 1 do a += 1 end');
deepEquals(errors, []);
})
deepEqualsAST('while a < 1 do a += 1 end', [
{
type: 'WhileStatement',
condition: {
type: 'BinaryExpression',
operator: '<',
left: { type: 'Identifier', name: 'a' },
right: { type: 'NumericLiteral', value: 1 },
},
block: {
type: 'Block',
body: [
{
type: 'AssignmentStatement',
variables: [{ type: 'Identifier', name: 'a' }],
operator: '+=',
init: [{ type: 'NumericLiteral', value: 1 }],
},
],
},
}]);
});

it('parses a one-line while statement', () => {
deepEqualsAST('while (a < 1) a += 1', [
Expand All @@ -430,7 +448,7 @@ end
type: 'BinaryExpression',
operator: '<',
left: { type: 'Identifier', name: 'a' },
right: { type: 'NumericLiteral', value: 1 }
right: { type: 'NumericLiteral', value: 1 },
},
block: {
type: 'Block',
Expand All @@ -439,10 +457,10 @@ end
type: 'AssignmentStatement',
variables: [{ type: 'Identifier', name: 'a' }],
operator: '+=',
init: [{ type: 'NumericLiteral', value: 1 }]
}
]
}
init: [{ type: 'NumericLiteral', value: 1 }],
},
],
},
}]);
});

Expand Down

0 comments on commit a4149e0

Please sign in to comment.