Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
How to concatenate two strings ?
posted

I just starting looking at the Parsing Framework and I'd like to ask how to concatenate two strings without space?

for example: the concatenation of "snow" and "ball" is "snowball",  not "snow ball"

?TERMINAL_SYMBOL? KEY1= ?IGNORE_CASE? "snow";
?TERMINAL_SYMBOL? KEY2= ?IGNORE_CASE? "ball";

?START? word =KEY1,KEY2;

?START? word = ??????????????????????????

Parents
No Data
Reply
  • 44743
    posted

    If you have a unit of text you would like the parser to treat as a single unit without ignoring insignificant text withing it (such as whitespace), then you should define it as a terminal symbol. So let's say you need the terminal symbol "snow" in some cases, "ball" in other cases, and "snowball" in some other cases. Then you should define three terminal symbols: "snow", "ball", and "snowball". The lexical analysis phase will choose the longest piece of text possible which forms a valid token, so when faced with the text "snowball", it will not create a "snow" token followed by a "ball" token. It will just create a single "snowball" token.

Children
No Data