/src/Editing/notes.txt

http://github.com/Eelis/geordi · Plain Text · 73 lines · 51 code · 22 blank · 0 comment · 0 complexity · abfff81ed2b81e28d984a8e7b65fe369 MD5 · raw file

  1. {- Command grammar:
  2. command = (insert | append | prepend | erase | replace | move | swap | wrap | use | make)*
  3. insert = ("insert" | "add") ... positions*
  4. append = "append" ... [positions*]
  5. prepend = "prepend" ... [positions*]
  6. erase = ("erase" | "remove" | "delete" | "cut" | "omit" | "kill") substrs*
  7. replace = "replace" (substrs* ("with" | "by") ...)*
  8. move = "move" (substr "to" position)*
  9. swap = "swap" (substr "and" substr)*
  10. wrap = "wrap" wrapping ("around" substrs*)* | "wrap" substrs* "in" wrapping
  11. use = "use" verbatim*
  12. make = "make" declarator-id* type-description
  13. wrapping = ... "and" ... | "parentheses" | "parens" | "braces" | "curlies"
  14. | ("square" | "angle" | "curly" | "round") "brackets" | ("single" | "double") "quotes"
  15. relative = between | befaft ranked
  16. substrs = declaration | range | ("everything" | rankeds) [relative]
  17. substr = declaration | range | ("everything" | ranked) [relative]
  18. declaration = "declaration" "of" declarator-id
  19. position = limit | befaft ("everything" | ranked)
  20. befaft = "before" | "after"
  21. positions = "at" limit | befaft (("everything" | rankeds) [befaft ranked])*
  22. ordinal = "first" | ("second" | "third" | etc) ["last"] | "last"
  23. ranked = [ordinal] ...
  24. rankeds = "all" [("except" | "but") ordinal*] ... | ["each" | "every" | "any" | ordinal*] ...
  25. between = "between" (bound "and" relative-bound | ordinal "and" ordinal ...)
  26. range = ([["everything"] "from"] bound | "everything") ("till" | "until") relative-bound
  27. limit = "begin" | "front" | "end" | "back"
  28. bound = limit | [befaft] ("everything" | ranked)
  29. relative-bound = limit | [befaft] ("everything" | ranked) [relative]
  30. Ellipsis denote a verbatim string, which may be quoted in backticks. Finally, x* = x ["and" x*].
  31. This is an idealized grammar with LOTS of ambiguity. The parsers do their best to choose the most sensible interpretation of ambiguous commands.
  32. Design notes:
  33. Consider "erase {x} and second {", given "{x}{y}". Here, "second {" has to be searched for in the original string, rather than the result of performing the first erase. However, consider "erase z" and move everything after x to front", given "xyz". The "everything after front" should /not/ include "z", but this requires performing the first erase. Also, consider "append z and move everything after x to front", given "xy". This should produce "yxz", not "yzx".
  34. "use" is heavily biased toward whole-token edits, so users are encouraged to use those. This will not only produce better edits, it is also more readable.
  35. Giving moves a single target makes "move 4 to end and 5 to begin" work, because otherwise it would be parsed as a move with two targets, the second of which, 5, is not a valid target.
  36. Should "second last x before y" in "xxaxxy" designate the 'x' before or after 'a'?
  37. We choose the latter, because it seems more natural, despite the curious result that "first x before y" now means the same as "last x before y".
  38. Should "erase all x and y" mean "erase all x and all y" or "erase all x and the sole y"?
  39. We choose the latter, because:
  40. - it's easier to implement, because we don't need "and"-repetition nested under "all";
  41. - it's safe, because if y occurs multiple times, a clear "y occurs multiple times" error will be emitted, whereas the former solution could result in unintended edit results.
  42. Should "first and second last x" mean "(first and second) last x" or "first and (second last) x"?
  43. I have no strong feelings on the matter. Currently it is interpreted to mean the second.
  44. Should "from ..." / "until ..." bounds be inclusive or exclusive?
  45. We choose the former, for no particular reason. Note that this default can be overridden by by saying "from after ..." / "until before ...".
  46. Grammar guidelines:
  47. - Ranges are never relative (but their bounds may be).
  48. - Position specifications never mention ranges (this means that "everything" must not be a range).
  49. Semantic choices:
  50. - Ordinal specifications are always relative to the full string, so "erase from x until second b" in "bxabcb" produces "bxbcb", not "bxb".
  51. -}