generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Parsing for optional static text

Previous Thread :: Next Thread 
MICHEAL1988351 is online. MICHEAL1988351
Joined: 26 Jan 2015
Total Posts: 582
08 Aug 2017 02:25 PM
[PLEASE NOTE] in the parsing expressions I will be using the following letters to represent symbols like the percent and multiplication due to roblox's filter:
p = %
m = *

I have a scenario in which I need to be able to match an optional static sub of text####a##tring, but that static portion could be 1 of 2 possibilities.

Here are some examples of possibilities that I need to be able to parse:
"foo + offset bar"

"*foo + bar"

"foo + bar"

"*foo + *bar"

"offset foo + offset bar"

where either "offset" or "*" should be optional in front of each identifier. (in this case "foo" and "bar")

Is there any actual way to do this using Lua's string matching? I was thinking of something like:

"[offset]?psmpm?psm[_pa][_pw]m" but "[offset]?" is only an optional character class that can either be o, f, s, e, or t; and even if it wasn't users would be able to send input like:

"offset * foo + offset * bar"

without getting a proper warning.

From a logical standpoint what I am trying to do would probably look something like

("offset" | "*" | "") & "psm[_pa][_pw]m"
Report Abuse
MICHEAL1988351 is online. MICHEAL1988351
Joined: 26 Jan 2015
Total Posts: 582
08 Aug 2017 02:59 PM
BUMP
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
08 Aug 2017 03:20 PM
I don't understand what you are trying to do.

Can you describe what you need to parse and what it should be parsed into?
Report Abuse
MICHEAL1988351 is online. MICHEAL1988351
Joined: 26 Jan 2015
Total Posts: 582
08 Aug 2017 03:41 PM
@chimmihc what I am trying to parse the given string into is kind of irrelevant since my question regards how to actually match a given optional format of static text within a given string using Lua's parse expressions.

If you need more info on the situation then here are some detailed examples; if a user sent in a string like such:

"foo + bar"

then the values foo and bar would be added, but if a user sent in a string like such:

"offset foo + bar"

then the virtual address of foo, and the value bar would be added. Like-wise if a user sent in a string like such:

"foo + * bar"

then the value foo and the value at the virtual address at bar would be added.

The problem is that an identifier like "foo", or "bar" can only be preceded by "offset" or "*" but both "offset" and "*" must be optional.

the logical example I gave kind of explains a pseudo code of what I am trying to do:
("offset" or "*" or "") and "psm[_pa][_pw]m"

(change all 'p's to %, and all 'm's to * in the Lua parse expression)
Report Abuse
MICHEAL1988351 is online. MICHEAL1988351
Joined: 26 Jan 2015
Total Posts: 582
08 Aug 2017 03:55 PM
BUMP
Report Abuse
Mescalyne is not online. Mescalyne
Joined: 20 Apr 2017
Total Posts: 418
08 Aug 2017 04:01 PM
Oh god, are you still trying to change Lua to a freaking C-like language? This is getting ridiculous.
I find it easier to create a tokenizer that processes a string like an input stream, character-by-character and determining token type along with that, too.
You can then (relatively) easily parse the tokens into expressions.
Report Abuse
MICHEAL1988351 is online. MICHEAL1988351
Joined: 26 Jan 2015
Total Posts: 582
08 Aug 2017 04:40 PM
########## yeah, I still am lol. Anyway thanks for the idea; I will try that out.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image