-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Ambiguity w/ the assignment of Strings #192
Comments
JavaScript is inferior to DreamBerd, never bring that language up again. 👿 |
for real tho, yeah, there will be several parts in dreamberd that (probably) couldn't be parsed deterministically |
here's a related comment #74 (comment) |
Hey if you were to build a DreamBerd to JavaScript compiler, this is what it would do: dreamberd
javascript
Hey, every feature can be done deterministically! For strings, if an error is found in the code, the parser traverses as far along as it can. The next character gets interpreted as a string - then it tries again to parse the code. If that fails again, the next TWO characters are interpreted as a string. It keeps adding more and more characters until it succeeds, or it reaches the end of the file(s). If it's at the end, and it still fails, then a compile-time error happens. If there are any other cases that you find ambiguous, please let me know :) |
WHAT |
@TeraByte-Official: I think that's valid JavaScript/ECMAScript. An expression can be used as a statement, I think, but has no effect, other than any side effects caused by evaluating the expression. (None, in this case.) Due to negative lifetimes, though, I think the code would have to be parsed before the scope of variables could be determined to decide whether something that looks like an identifier is actually an identifier, or should be interpreted as an unquoted string. The easiest approach, I think, would be to only allow unquoted strings that look like identifiers. (That seems to be the approach suggested in the linked comment too.) |
Given that strings are currently meant to function with 0 quotes, I'm wondering how strings such as:
const const 8 = Hello! World!
Can be included without a compiler error. When attempting to run the following code, the compiler threw the following error log:
`The provided code is not valid JavaScript syntax and would result in a syntax error.
In JavaScript, variable names cannot start with a number, and "const" is a reserved keyword used to declare a constant variable. Additionally, variable names cannot contain spaces or exclamation marks.
If you want to declare a constant variable with the value "Hello! World!", you can modify the code to adhere to the JavaScript syntax rules, like this:
const myConstant = 'Hello! World!';
In this example, the variable myConstant is declared using the const keyword and assigned the string value 'Hello! World!'.`
The text was updated successfully, but these errors were encountered: