File: upper.kpeg

package info (click to toggle)
ruby-kpeg 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: ruby: 11,839; makefile: 10
file content (24 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%% name = Upper


%% {
    attr_accessor :output
}

period = "."
space = " "
alpha = < /[A-Za-z]/ > { text.upcase }

word = alpha:a word:w { "#{a}#{w}" }
      | alpha:a space { "#{a} "}    
      | alpha:a { a }

sentence = word:w sentence:s { "#{w}#{s}" }
          | word:w { w }

document = sentence:s period space* document:d  { "#{s}. #{d}" }
          | sentence:s period { "#{s}." }
          | sentence:s { "#{s}" }

root = document:d { @output = d }