Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Jul 5, 2022
1 parent 74d1e5e commit f95a22e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Clause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ export default class Clause extends Builder {
} else {
const signature = clause.signature;
let kind: AlgorithmType | undefined =
clause.type != null && aoidTypes.includes(clause.type) ? clause.type as AlgorithmType : undefined;
clause.type != null && aoidTypes.includes(clause.type)
? (clause.type as AlgorithmType)
: undefined;
// @ts-ignore
if (kind === 'sdo') {
kind = 'syntax-directed operation';
Expand Down
12 changes: 9 additions & 3 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,14 @@ export default class Spec {
}

if (biblioEntry.kind === 'syntax-directed operation' && expr.type === 'call') {
warn(`${calleeName} is a syntax-directed operation and should not be invoked like a regular call`);
} else if (biblioEntry.kind != null && biblioEntry.kind !== 'syntax-directed operation' && expr.type === 'sdo-call') {
warn(
`${calleeName} is a syntax-directed operation and should not be invoked like a regular call`
);
} else if (
biblioEntry.kind != null &&
biblioEntry.kind !== 'syntax-directed operation' &&
expr.type === 'sdo-call'
) {
warn(`${calleeName} is not a syntax-directed operation but here is being invoked as one`);
}

Expand Down Expand Up @@ -2154,7 +2160,7 @@ function isConsumedAsCompletion(expr: Expr, path: PathItem[]) {
const { parent, index } = part;
if (parent.type === 'seq') {
// if the previous text ends in `! ` or `? `, this is a completion
let text = textFromPreviousPart(parent, index as number);
const text = textFromPreviousPart(parent, index as number);
if (text != null && /[!?]\s$/.test(text)) {
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions src/expr-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ function formatClose(close: CloseTokenType[]) {
function addProse(items: NonSeq[], token: Token) {
// sometimes we determine after seeing a token that it should not have been treated as a token
// in that case we want to join it with the preceding prose, if any
let prev = items[items.length - 1];
const prev = items[items.length - 1];
if (token.type === 'prose') {
if (prev == null || prev.type !== 'prose') {
items.push(token);
} else {
let lastPartOfPrev = prev.parts[prev.parts.length - 1];
let firstPartOfThis = token.parts[0];
const lastPartOfPrev = prev.parts[prev.parts.length - 1];
const firstPartOfThis = token.parts[0];
if (lastPartOfPrev?.name === 'text' && firstPartOfThis?.name === 'text') {
items[items.length - 1] = {
type: 'prose',
Expand Down Expand Up @@ -500,12 +500,12 @@ class ExprParser {
}
case 'x_of': {
this.next.shift();
let callee = next.source.split(' ')[0];
const callee = next.source.split(' ')[0];
if (!this.opNames.has(callee)) {
addProse(items, next);
break;
}
let parseNode = this.parseSeq([
const parseNode = this.parseSeq([
'eof',
'period',
'comma',
Expand All @@ -514,7 +514,7 @@ class ExprParser {
'crec',
'with_args',
]);
let args: Seq[] = [];
const args: Seq[] = [];
if (this.peek().type === 'with_args') {
this.next.shift();
while (true) {
Expand Down

0 comments on commit f95a22e

Please sign in to comment.