String manipulation in Javalette By Daniel Bostrm and Sebastian - - PowerPoint PPT Presentation

string manipulation in javalette
SMART_READER_LITE
LIVE PREVIEW

String manipulation in Javalette By Daniel Bostrm and Sebastian - - PowerPoint PPT Presentation

String manipulation in Javalette By Daniel Bostrm and Sebastian Salman http://www.dtek.chalmers.se/~salman/javalette/ Adding String Manipulation to Javalette Original version of Javalette lacked string handling. Only support for


slide-1
SLIDE 1

String manipulation in Javalette

By Daniel Boström and Sebastian Salman http://www.dtek.chalmers.se/~salman/javalette/

slide-2
SLIDE 2

Adding String Manipulation to Javalette

  • Original version of Javalette lacked string

handling.

  • Only support for strings was using the hardcoded

printString(“...”) function.

  • No support for comparing strings or manipulating

them.

slide-3
SLIDE 3

New String features

  • Variables of type String can now be declared.
  • Functions can accept parameters of the type

String.

  • Strings can be compared to each other (!= == <

<= > >=).

  • Strings can be compared to integers (will

compare with the length of the string).

slide-4
SLIDE 4
  • Possible to look for a matching sub string with

the / operator: boolean b = (“x” / “xyz”);

  • Strings can be added like: String s =

“aoeu”+”htns”;

More features

slide-5
SLIDE 5

Regular Expressions

  • How to interpret and check the regex?
  • Using Non-deterministic Finite Automata.
  • Run the NFA with the string as input.
slide-6
SLIDE 6

The NFA

  • Three basic building blocks

– Concatenation

  • ab

– Alternation

  • a|b

– Star (Kleen closure)

  • a*
  • Using these, other rules can be formed

– a+ => aa*

slide-7
SLIDE 7

Examples

int main() { printBool( regex_matches(“aab”, “aab”) ); //true printBool( regex_matches(“a*b”, “b”) ); //true printBool( regex_matches(“a+b”, “b”) ); //false return 0; }