You are here

Neon Scripting Language (Suggestions Wanted)

6 posts / 0 new
Last post
John Bentley
John Bentley's picture
Offline
Last seen: 14 years 11 months ago
Developer
Joined: 2006-01-24 13:26
Neon Scripting Language (Suggestions Wanted)

This is a project I have been working on. It is a scripting language written in C++. It currently is almost fully functional. (It doesn't support ifs whiles or declaring functions or classes.) I am looking at expanding the library. I already plan on making a GUI and IO library with wxWidgets. I currently need the following.

  • A string replace algorithm
  • A regular expression library
  • Anything else that might be useful

Thank you.

digitxp
digitxp's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2007-11-03 18:33
And I didn't even look on Google

I found this thread:
http://www.idevgames.com/forum/archive/index.php/t-11611.html
I have no idea how it's useful.
Well, here are some commands:

  • Var
  • If
  • Then
  • While
  • Else
  • Sleep
  • Run
  • DOSExec
  • VarValue (like strcpy in NSIS)
  • CallAPI

http://www.autohotkey.com/docs/commands.htm would be a good place to check for commands.
I bet John (Haller) would like a scripting language that is specifically designed for creating PortableApps :P.
Oh, and a string replace algorithm, hm... Maybe check out strrep.nsh in NSIS, here I'll fetch it for you:

; StrReplace
; Replaces all ocurrences of a given needle within a haystack with another string
; Written by dandaman32
 
Var STR_REPLACE_VAR_0
Var STR_REPLACE_VAR_1
Var STR_REPLACE_VAR_2
Var STR_REPLACE_VAR_3
Var STR_REPLACE_VAR_4
Var STR_REPLACE_VAR_5
Var STR_REPLACE_VAR_6
Var STR_REPLACE_VAR_7
Var STR_REPLACE_VAR_8
 
Function StrReplace
  Exch $STR_REPLACE_VAR_2
  Exch 1
  Exch $STR_REPLACE_VAR_1
  Exch 2
  Exch $STR_REPLACE_VAR_0
    StrCpy $STR_REPLACE_VAR_3 -1
    StrLen $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_1
    StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
    loop:
      IntOp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_3 + 1
      StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_3
      StrCmp $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_1 found
      StrCmp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_6 done
      Goto loop
    found:
      StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_3
      IntOp $STR_REPLACE_VAR_8 $STR_REPLACE_VAR_3 + $STR_REPLACE_VAR_4
      StrCpy $STR_REPLACE_VAR_7 $STR_REPLACE_VAR_0 "" $STR_REPLACE_VAR_8
      StrCpy $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_5$STR_REPLACE_VAR_2$STR_REPLACE_VAR_7
      StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
      Goto loop
    done:
  Pop $STR_REPLACE_VAR_1 ; Prevent "invalid opcode" errors and keep the
  Pop $STR_REPLACE_VAR_1 ; stack as it was before the function was called
  Exch $STR_REPLACE_VAR_0
FunctionEnd
 
!macro _strReplaceConstructor OUT NEEDLE NEEDLE2 HAYSTACK
  Push "${HAYSTACK}"
  Push "${NEEDLE}"
  Push "${NEEDLE2}"
  Call StrReplace
  Pop "${OUT}"
!macroend
 
!define StrReplace '!insertmacro "_strReplaceConstructor"'

I can't wait for a home brew scripting language (BTW, why neon, well, I would suppose helium would be a file recovery program...)

Insert original signature here with Greasemonkey Script.

John Bentley
John Bentley's picture
Offline
Last seen: 14 years 11 months ago
Developer
Joined: 2006-01-24 13:26
I don't know how much the

I don't know how much the NSIS string replace code will help considering my skills at NSIS and it is most likely that it is less efficient due to the way NSIS works.

I picked the name Neon because it was the one that seemed to fit the best.

Thanks for the links, btw.

cowsay Moo
cowthink 'Dude, why are you staring at me.'

Steve Lamerton
Steve Lamerton's picture
Offline
Last seen: 10 years 10 months ago
Developer
Joined: 2005-12-10 15:22
Surely

the C++ string library you use will have a string replace library? If not there is a fairly decent looking example in the wxWidgets source, but it is specifically for the wxString. Find it under src\common\string.cpp

John Bentley
John Bentley's picture
Offline
Last seen: 14 years 11 months ago
Developer
Joined: 2006-01-24 13:26
It doesn't. I am using

It doesn't. I am using std::basic_string<TCHAR>. (Pretty much the same as std::string except with unicode.) It doesn't seem to have a replace method that replaces a substring. The replace method requires you to have the start and end position.

cowsay Moo
cowthink 'Dude, why are you staring at me.'

m2
Offline
Last seen: 13 years 5 months ago
Joined: 2006-12-12 12:00
The most commonly used regexp

The most commonly used regexp library is pcre.
You can also use it to make string replace, it shouldn't be slow.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

Log in or register to post comments