Last change
on this file since 17 was 17, checked in by Tatsukawa, Akimichi, 16 years ago |
begin to add scanner module using yaparc
|
File size:
1.9 KB
|
Rev | Line | |
---|
[17] | 1 | require 'logger'
|
---|
| 2 | require 'rubygems'
|
---|
| 3 | require 'yaparc'
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | module OpenEHR
|
---|
| 8 | module ADL
|
---|
| 9 | module Scanner
|
---|
| 10 | module DADL
|
---|
| 11 | # c.f. http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/adl/parser/adl_scanner.l
|
---|
| 12 | @@dadl_reserved = {
|
---|
| 13 | 'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE
|
---|
| 14 | 'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE
|
---|
| 15 | 'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | LOG = Logger.new('log/scanner.log')
|
---|
| 19 |
|
---|
| 20 | class RootScanner
|
---|
| 21 | include Yaparc::Parsable
|
---|
| 22 | def initialize
|
---|
| 23 | @parser = lambda do |input|
|
---|
| 24 | Yaparc::Alt.new(
|
---|
| 25 | V_QUALIFIED_TERM_CODE_REF.new,
|
---|
| 26 | V_LOCAL_TERM_CODE_REF.new
|
---|
| 27 | )
|
---|
| 28 | end
|
---|
| 29 | end
|
---|
| 30 | end
|
---|
| 31 |
|
---|
| 32 | class V_QUALIFIED_TERM_CODE_REF
|
---|
| 33 | include Yaparc::Parsable
|
---|
| 34 | def initialize
|
---|
| 35 | @parser = lambda do |input|
|
---|
| 36 | Yaparc::Apply.new(Yaparc::Regex.new(/\A\[[a-zA-Z0-9()\._-]+::[a-zA-Z0-9\._-]+\]/)) do |match|
|
---|
| 37 | LOG.info("V_QUALIFIED_TERM_CODE_REF: #{match}")
|
---|
| 38 | [:V_QUALIFIED_TERM_CODE_REF, match]
|
---|
| 39 | end
|
---|
| 40 | end
|
---|
| 41 | end
|
---|
| 42 | end
|
---|
| 43 |
|
---|
| 44 | class V_LOCAL_TERM_CODE_REF
|
---|
| 45 | include Yaparc::Parsable
|
---|
| 46 | def initialize
|
---|
| 47 | @parser = lambda do |input|
|
---|
| 48 | Yaparc::Apply.new(Yaparc::Regex.new(/\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/)) do |match|
|
---|
| 49 | LOG.info("V_TERM_CODE_REF: #{match}")
|
---|
| 50 | [:V_LOCAL_TERM_CODE_REF, match]
|
---|
| 51 | end
|
---|
| 52 | end
|
---|
| 53 | end
|
---|
| 54 | end
|
---|
| 55 | end # of DADL
|
---|
| 56 | module CADL
|
---|
| 57 | # c.f. http://www.openehr.org/svn/ref_impl_eiffel/TRUNK/components/adl_parser/src/syntax/cadl/parser/cadl_scanner.l
|
---|
| 58 | end
|
---|
| 59 | end
|
---|
| 60 | end
|
---|
| 61 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.