Ask coding questions

← Back to all posts
HELP NEEDED WITH CREATING A LANGUAGE!
[deleted]

So, I have this language that I have been developing. It uses Regex's to "translate" Hsuya's(My language) code to JavaScript. This works well and all but, I want to make it have errors. If anyone could help me with that, that would be great!

Answered by Coder100 (18168) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18168)

Would you like to see the tutorial I used to learn to program the language?
https://craftinginterpreters.com
it is only slightly biased towards the fact that it is a class-based language, but it should be a very good start.

[deleted]

Thank you all for your helpful comments. I realize I wasn't asking the right question. As I stated, I created this using Regex's that transpiled it to JavaScript but I would like to add my own errors for this language because at the time it is not really showing them. Here is a picture of what I mean:


Coder100 (18168)

oh, well ideally you should catch those errors yourself. You would need some way to actually know what that string was, and you would do that by actually parsing through the text. RegEx can only go so far when making a language. @AJK4

[deleted]

Okay, now I understand. @Coder100

programmeruser (596)

@Coder100 I just read the source code of cookeylang lol
(it's really just a implementation of the principles in Crafting Interpreters)

Coder100 (18168)

lol yeah it is
when you use a tutorial your code usually is based on the logic of the tutorial @programmeruser

DissertationAid (0)

The only other language that French has, as far as I know, influenced to a significant extant is Creole French, which has lots in common but is really too different to be called a simple dialect.
https://brandaxio.com/

BrianMckay (0)

Javascript is not only simple to use and flexible, but those who know how to use it are in high demand. Companies are still on the lookout for Javascript experts. Javascript is a great language to learn because the skills you learn from online Javascript courses are very transferable. https://britishdissertationhelp.co.uk/

xxpertHacker (930)

@CoderCactus Hey, can you check this out?

This post is being bot upvoted by new, 0 cycle accounts.

@AjkBot
@Deepjk
@AJK14
@AJK4
^ Obvious examples

I think just reading the names of these accounts is enough to show that these are bots, especially considering how the last two are similiar in more than just username.

I was going to report this, but the report box has a size limit of 0xFF chars :/

[deleted]

Those have been there before I got warned by a Moderator. Once I got warned I stopped doing it. @xxpertHacker

xxpertHacker (930)

@AJK4 Oh, maybe that was a useless ping then

xxpertHacker (930)

Options:
A) Validate the input, if it's invalid, throw an exception.
B) Validate the output, if the output isn't valid JS, throw an exception.
C) JavaScript is not a compilation target, Wasm is. (validating is as simple as calling WebAssembly.validate(output))

Regarding (B), if your output is incorrect, I'd consider it to be a compiler error, parse correctly and this won't happen.

[deleted]

Thanks! @xxpertHacker

xxpertHacker (930)

@AJK4 Btw, I'd recommend using Coder100's answer, and using a parsing/lexing library instead of RegEx. You don't have to reinvent the wheel and parse by hand (it may even slow you down in fact), but ECMAScript RegEx won't help, recursive RegEx would be better, ex: PCRE syntax, but JS doesn't have anything else.

Just try to get a better parser that can stop when something isn't correct, so you can handle it yourself, or throw an error and abort the program.

RYANTADIPARTHI (6018)

wdym by real language? Do you mean host it on the web or something?

19wintersp (1142)

I'm not sure what you mean by a "real" language; a transpiled language is still a language (think of TypeScript, for example). If you want to create a language which compiles to binaries, look into the LLVM.

xxpertHacker (930)

@19wintersp Oh nice, use RegEx to parse text into LLVM code, then compile to native machine binary. Smart.