Skip to content

Commit

Permalink
Remove visitor pattern and add descriptions (#7361)
Browse files Browse the repository at this point in the history
* WIP

* Remove Javascript interpreter

* Add tests for all exercises

* Tidy imports

* Tidy imports

* Remove visitor pattern and add descriptions

* Improve descriptions further

* Keep simplifying
  • Loading branch information
iHiD authored Jan 22, 2025
1 parent 7034396 commit 86e1fc1
Show file tree
Hide file tree
Showing 23 changed files with 930 additions and 992 deletions.
7 changes: 5 additions & 2 deletions app/css/bootcamp/components/editor-information-tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
@apply bg-thick-border-blue px-[6px] py-[1px] rounded-5;
}

pre + p {
@apply mt-6;
}
pre {
@apply mt-4;
@apply mt-2;
}

p:not(:last-of-type) {
p:not(:last-child) {
@apply mb-10;
}
ul {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class InformationWidget extends WidgetType {
if (!this.tooltip) return
this.arrowElement = document.createElement('div')
this.arrowElement.classList.add('tooltip-arrow')
this.tooltip.appendChild(this.arrowElement)
this.tooltip.prepend(this.arrowElement)
}

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/interpreter/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export type SyntaxErrorType =
| 'MissingColonAfterKey'
| 'MissingFieldNameOrIndexAfterOpeningBracket'
| 'InvalidTemplateLiteral'
| 'MissingColonAfterThenBranchOfTernaryOperator'
| 'NumberEndsWithDecimalPoint'
| 'NumberWithMultipleDecimalPoints'
| 'NumberContainsAlpha'
Expand Down Expand Up @@ -108,6 +107,7 @@ export type RuntimeErrorType =
| 'InvalidIndexSetterTarget'
| 'UnexpectedEqualsForEquality'
| 'VariableAlreadyDeclared'
| 'VariableNotDeclared'

export type StaticErrorType =
| DisabledLanguageFeatureErrorType
Expand Down
32 changes: 7 additions & 25 deletions app/javascript/interpreter/evaluation-result.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
import type { TokenType } from './token'

export type EvaluationResultVariableStatement = {
type: 'VariableStatement'
export type EvaluationResultSetVariableStatement = {
type: 'SetVariableStatement'
value: any
name: string
data?: Record<string, any>
}

export type EvaluationResultTernaryExpression = {
type: 'TernaryExpression'
value: any
condition: EvaluationResult
data?: Record<string, any>
}

export type EvaluationResultUpdateExpression = {
type: 'UpdateExpression'
operand: any
operator: any
value: any
newValue: any
data?: Record<string, any>
}

export type EvaluationResultIfStatement = {
type: 'IfStatement'
value: any
Expand Down Expand Up @@ -105,11 +89,10 @@ export type EvaluationResultConstantStatement = {
data?: Record<string, any>
}

export type EvaluationResultAssignExpression = {
type: 'AssignExpression'
export type EvaluationResultChangeVariableStatement = {
type: 'ChangeVariableStatement'
name: string
operator: TokenType
value: any
oldValue: any
newValue: any
data?: Record<string, any>
}
Expand Down Expand Up @@ -171,10 +154,9 @@ export type EvaluationResultCallExpression = {
}

export type EvaluationResult =
| EvaluationResultVariableStatement
| EvaluationResultSetVariableStatement
| EvaluationResultUpdateExpression
| EvaluationResultConstantStatement
| EvaluationResultTernaryExpression
| EvaluationResultIfStatement
| EvaluationResultExpressionStatement
| EvaluationResultForeachStatement
Expand All @@ -188,7 +170,7 @@ export type EvaluationResult =
| EvaluationResultBinaryExpression
| EvaluationResultUnaryExpression
| EvaluationResultGroupingExpression
| EvaluationResultAssignExpression
| EvaluationResultChangeVariableStatement
| EvaluationResultGetExpression
| EvaluationResultSetExpression
| EvaluationResultTemplateTextExpression
Expand Down
Loading

0 comments on commit 86e1fc1

Please sign in to comment.