So, in my progress with QuickCode, I decided to make a tiny language in JavaScript just to test my theory about how I will go about making QuickCode.
Basically, the only function in this mini language is "dialog."
Example:
dialog Hello
So this is the JS code I have so far for my parser:
dialogFunc = /^(dialog)\s(\w+)$/
function submitIt(myForm) {
if (dialogFunc.test(myForm.quickCode.value)) {
alert()
return false
}
alert("Invalid code!")
return false
}Now, on the line
alert()
right under the if () statement, I want the alert to display the substring
(\w+)
of the regular expression as a string.
I need help on how to get the alert to do that!
Offline
Nevermind, I finally got it after experimenting for a while
alert(RegExp.$2)
I was overthinking it
Offline
Nice username
Offline
rubiks_cube_guy238 wrote:
Nice username
![]()
Thanks.
Offline
This is very interesting. Does it work so far?
Offline
Well, this tiny little programming language that I posted above works. My main project is QuickCode, and there's more about it in another thread on the Advanced Topics forum (I forgot the link). The QuickCode parser itself is about 1/2 done now, as I am continually hampered with bugs. So overall, it's coming along nicely, but I've still got a lot of work to do.
Offline
ohaiderstudios wrote:
Well, this tiny little programming language that I posted above works. My main project is QuickCode, and there's more about it in another thread on the Advanced Topics forum (I forgot the link). The QuickCode parser itself is about 1/2 done now, as I am continually hampered with bugs. So overall, it's coming along nicely, but I've still got a lot of work to do.
![]()
Very cool.
Offline