Guest User

Untitled

a guest
Oct 25th, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. To put it briefly, a program matches /rule*input/
  2.  
  3. A rule is composed of regexp, -> sign and something I call a segexp (just because S goes after R)
  4.  
  5. A regexp is a string enclosed in double quotes. *, + (instead of |) and parentheses work as you'd expect them. There is an additional element - a name prefix. This is a string enclosed in [] followed by a regexp. This name is going to be used by segexp. Name prefix has precedence between * and +. To use symbols ", *, +, (, ), [, ], \ in a regexp as normal characters, prefix them with a \.
  6.  
  7. Example: "[x](0+1)*1"
  8. This matches all binary strings that end with 1. All characters but the last one are given a name [x].
  9.  
  10. A segexp is a string enclosed in double quotes. It is composed of symbols and names. A name is the same as in regexp. Whatever was assigned to it will be inserted here. If that name was not used, nothing is inserted (no error either). Symbols ", [, ], \ may need a \ prefix.
  11.  
  12. Example: "[x]0[x][y]"
  13. If used with the regexp of last example and a string 101, it will produce a string 10010
  14.  
  15. An input is again a string in ". It only has characters. only " and \ need a \.
  16.  
  17. The input is matched to each rule in the order they are written in the file. If a match occurs, input is replaced with whatever segexp built and matching starts from the top of the list again.
  18. When no rule matches, the current string is printed.
  19.  
Advertisement
Add Comment
Please, Sign In to add comment