Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are the types of compiler errors? #242

Open
mhagmajer opened this issue Jun 26, 2020 · 6 comments
Open

What are the types of compiler errors? #242

mhagmajer opened this issue Jun 26, 2020 · 6 comments
Labels
AskScript ./src/askscript/** AskVM ./src/askvm/** discussion A discussion is taking place, please don't work on it yet
Milestone

Comments

@mhagmajer
Copy link
Collaborator

What are the types of errors that run and parse can throw?

@mhagmajer mhagmajer added question Further information is requested AskScript ./src/askscript/** AskVM ./src/askvm/** labels Jun 26, 2020
@czerwinskilukasz1
Copy link
Collaborator

@mhagmajer
There are roughly 40 error instances in 20 files in askvm/, askjsx/ and askcode/:
https://github.com/xFAANG/askql/search?q=%22new+Error%22&unscoped_q=%22new+Error%22&type=Code

I would create a class hierarchy for them, e.g.:
Error, with subclasses

  • ParseError
  • CompileError
  • RuntimeError

RuntimeError with subclasses, each error type being a separate subclass, e.g.:

  • InvalidResourceRuntimeError for this error
  • NotAnArrayRuntimeError for this and this error
  • InvalidTypeRuntimeError for this error
    and so on

@mhagmajer
Copy link
Collaborator Author

@czerwinskilukasz1 why class hierarchy and not plan object with type? Maybe we should avoid OOP to make it easier to port AskVM to non-oop languages such as C

@czerwinskilukasz1
Copy link
Collaborator

@mhagmajer , I am fine with either, with a preference for classes, because they make the code more reusable and cleaner.

If we were to port AskVM to other languages, we would need much work anyway as we are using pretty many Typescript and Javascript features, like:

  • instanceOf,
  • Array.isArray,
  • JSX templates,
  • ES template literals,
  • throw (including throw new Error)
    to name a few.
    So adding more classes for Errors would have small impact on the whole porting task.

@mhagmajer
Copy link
Collaborator Author

  • instanceOf,
  • Array.isArray,
  • JSX templates,
  • ES template literals,
  • throw (including throw new Error)
    to name a few.
    So adding more classes for Errors would have small impact on the whole porting task.

These are all functions. I'm not sure how to reflect class hierarchy in AskScript while not introducing classes. Maybe with explicit prototypal inheritance?

@czerwinskilukasz1
Copy link
Collaborator

  • instanceOf,
  • Array.isArray,
  • JSX templates,
  • ES template literals,
  • throw (including throw new Error)
    to name a few.
    So adding more classes for Errors would have small impact on the whole porting task.

These are all functions. I'm not sure how to reflect class hierarchy in AskScript while not introducing classes. Maybe with explicit prototypal inheritance?

I don't think there is prototypal inheritance in C.
How about we put all the thought regarding porting AskVM to C here: #143 ?

@mhagmajer
Copy link
Collaborator Author

@czerwinskilukasz1 prototypal inheritance is actually pretty easy to implement - you just need a pointer for the prototype. We use it for creating new environment (scope) when running functions

@czerwinskilukasz1 czerwinskilukasz1 added discussion A discussion is taking place, please don't work on it yet and removed question Further information is requested labels Jul 1, 2020
@czerwinskilukasz1 czerwinskilukasz1 added this to the v1.4 milestone Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AskScript ./src/askscript/** AskVM ./src/askvm/** discussion A discussion is taking place, please don't work on it yet
Projects
None yet
Development

No branches or pull requests

2 participants