File: sample2.rex

package info (click to toggle)
ruby-oedipus-lex 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 240 kB
  • sloc: ruby: 1,218; lisp: 12; ansic: 5; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# sample2.rex
# lexical definition sample for rex
#
# usage
#  rex  sample2.rex  --stub
#  ruby sample2.rex.rb  sample2.bas
#

class Sample2
macro
  BLANK         /\s+/
  REMARK        /\'/              # '

rule
                /{{REMARK}}/    :REM
  :REM          /\n/            { [:state, nil] }
  :REM          /.*(?=$)/       { [:remark, text] }

                /\"[^"]*\"/     { [:string, text] }

                /{{BLANK}}/     # no action

                /INPUT/i        { [:input, text] }
                /PRINT/i        { [:print, text] }

                /\d+/           { [:digit, text.to_i] }
                /\w+/           { [:word, text] }
                /./             { [text, text] }
end