Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Jun 9, 2023
1 parent 69e9bfa commit 819321e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions nois.bnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: boolean
// TODO: list constructor
// TODO: match expression
module ::= statement*
;
statement ::= var-def | fn-def | type-def | return-stmt | expr
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ const parser = new Parser(tokens)
parseModule(parser)
const root = parser.buildTree()

for (const error of parser.errors) {
console.error(prettySourceMessage(prettySyntaxError(error), error.got.location.start, source))
if (parser.errors.length > 0) {
for (const error of parser.errors) {
console.error(prettySourceMessage(prettySyntaxError(error), error.got.location.start, source))
}
process.exit(1)
}

Expand Down
3 changes: 3 additions & 0 deletions src/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const indexToLocation = (index: number, source: Source): Location | undef
return undefined
}

/**
* TODO: context lines parameter
*/
export const prettyIndex = (index: number, source: Source): string => {
const start = indexToLocation(index, source)
if (!start) return '<outside of a file>'
Expand Down

0 comments on commit 819321e

Please sign in to comment.