string manipulation in javalette
play

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


  1. String manipulation in Javalette By Daniel Boström and Sebastian Salman http://www.dtek.chalmers.se/~salman/javalette/

  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.

  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).

  4. More features ● Possible to look for a matching sub string with the / operator: boolean b = (“x” / “xyz”); ● Strings can be added like: String s = “aoeu”+”htns”;

  5. Regular Expressions ● How to interpret and check the regex? ● Using Non-deterministic Finite Automata. ● Run the NFA with the string as input.

  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*

  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; }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend