2009-05-01から1ヶ月間の記事一覧

libharu:HPDFDestination#set_fit_b

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange#getMaximumDouble

import org.apache.commons.lang.math.IntRange; public class C2009053100 { public static void main(String[] args) { System.out.println(new IntRange(1, 3).getMaximumDouble()); } } で、 3.0

runtime.Scanner#peek

#!/usr/bin/env python import re from yapps import runtime patterns = [ ('END', re.compile('$')), ('A', re.compile('a')), ('B', re.compile('b')), ] s = runtime.Scanner(patterns, {}, "abcb") print s.peek('A', 'B') print s.scan('A') で、 A a

libharu:HPDFDestination#set_fit_r

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange#equals

import org.apache.commons.lang.math.IntRange; public class C2009053000 { public static void main(String[] args) { System.out.println(new IntRange(1, 3).equals(new IntRange(1, 3))); System.out.println(new IntRange(1, 3).equals(new IntRange(…

runtime.Scanner#getchar

#!/usr/bin/env python import re from yapps import runtime patterns = [ ('END', re.compile('$')), ('A', re.compile('a')), ('B', re.compile('b')), ] s = runtime.Scanner(patterns, {}, "abcb") print s.getchar() print s.getchar() print s.getcha…

libharu:HPDFDestination#set_fit_v

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange#containsRange

import org.apache.commons.lang.math.IntRange; public class C2009052900 { public static void main(String[] args) { System.out.println(new IntRange(1, 3).containsRange(new IntRange(1, 3))); System.out.println(new IntRange(1, 3).containsRange…

runtime.Scanner#scan

#!/usr/bin/env python import re from yapps import runtime patterns = [ ('END', re.compile('$')), ('A', re.compile('a')), ('B', re.compile('b')), ] s = runtime.Scanner(patterns, {}, "aab") print s.scan('A') print s.scan('A') print s.scan('B…

libharu:HPDFDestination#set_fit_h

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange#containsNumber

import org.apache.commons.lang.math.IntRange; public class C2009052800 { public static void main(String[] args) { System.out.println(new IntRange(1, 3).containsNumber(0)); System.out.println(new IntRange(1, 3).containsNumber(1)); System.ou…

Parser を継承して利用

%% parser Test: token END: "$" token A: "a" rule start: A END {{ self.print_a() }} %% と #!/usr/bin/env python import m20090528_yapps200 from yapps import runtime class TestX(m20090528_yapps200.Test): def parse(self, rule): return runtime.…

libharu:HPDFDestination#set_fit

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange#containsInteger

import org.apache.commons.lang.math.IntRange; public class C2009052700 { public static void main(String[] args) { System.out.println(new IntRange(1, 3).containsInteger(0)); System.out.println(new IntRange(1, 3).containsInteger(1)); System.…

オプション「[]」

%% parser Test: token END: "$" token A: "a" token B: "b" rule start: A [B] A {{ print "*ab?a*" }} %% if __name__=='__main__': while 1: try: s = raw_input('>>> ') except EOFError: break if not s.strip(): break parse('start', s) print 'Bye.'…

libharu:HPDFDestination#set_xyz

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、IntRange

import org.apache.commons.lang.math.IntRange; public class C2009052600 { public static void main(String[] args) { System.out.println(new IntRange(3)); System.out.println(new IntRange(1, 3)); System.out.println(new IntRange(new Integer(3)))…

左再帰

%% parser Test: token END: "$" token NUM: "\d+" rule start: sum END {{ print sum }} rule sum : NUM {{ return NUM }} | sum "+" NUM {{ return (sum, NUM) }} %% if __name__=='__main__': while 1: try: s = raw_input('>>> ') except EOFError: brea…

libharu:HPDFPage#create_destination, HPDFOutline#set_destination

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、Validate.notNull()

import org.apache.commons.lang.Validate; public class C2009052500 { public static void main(String[] args) { Validate.notNull("hoge", "foo"); Validate.notNull("", "foo"); Validate.notNull(null, "foo"); } } で、 Exception in thread "main" j…

あいまいな文法

%% parser Test: token END: "$" token A: "a" token B: "b" token C: "c" rule start: A B END {{ print "*ab*" }} | A C END {{ print "*ac*" }} %% if __name__=='__main__': while 1: try: s = raw_input('>>> ') except EOFError: break if not s.strip…

libharu:HPDFOutline#set_opend

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE) pdf.use_jp_fonts pdf.use_jp_encodings encoder = pdf.get_encoder("90ms-RKSJ-H") o1 = pdf.create_outline(nil, "ア…

Commons Lang、Validate.notNull()

import org.apache.commons.lang.Validate; public class C2009052400 { public static void main(String[] args) { Validate.notNull("hoge"); Validate.notNull(""); Validate.notNull(null); } } で、 Exception in thread "main" java.lang.IllegalArgum…

examples/calc.g

| "\\(" expr "\\)" {{ return expr }}は | "\\(" expr<<V>> "\\)" {{ return expr }}のような気がする 修正前 >>> let x = 20 in (x+1) Traceback (most recent call last): File "calc.py", line 135, in ? parse('goal', s) File "calc.py", line 117, in pa</v>…

libharu:HPDFAnnotation#set_opened

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page a = page.create_text_annot(0, 0, 100, 100, "foo", pdf.get_current_encoder) a.set_opened(1) a = page.create_text_annot(0, 100, 100, 200, "foo", pdf.get_current_encoder…

Commons Lang、Validate.notEmpty()

import org.apache.commons.lang.Validate; public class C2009052300 { public static void main(String[] args) { Validate.notEmpty("hoge", "foo"); Validate.notEmpty("", "foo"); } } で、 Exception in thread "main" java.lang.IllegalArgumentExcep…

字句解析:トークンの選ばれ方

%% parser Test: token END: "$" token A: "a" token AA: "aa" rule start: A A END {{ print "*a a*" }} | AA END {{ print "*aa*" }} %% if __name__=='__main__': while 1: try: s = raw_input('>>> ') except EOFError: break if not s.strip(): break p…

libharu:HPDFAnnotation#set_icon

#!/usr/bin/env ruby require "hpdf" pdf = HPDFDoc.new page = pdf.add_page y = 0 [HPDFDoc::HPDF_ANNOT_ICON_COMMENT, HPDFDoc::HPDF_ANNOT_ICON_KEY, HPDFDoc::HPDF_ANNOT_ICON_NOTE, HPDFDoc::HPDF_ANNOT_ICON_HELP, HPDFDoc::HPDF_ANNOT_ICON_NEW_PARA…

Commons Lang、Validate.notEmpty()

import org.apache.commons.lang.Validate; public class C2009052200 { public static void main(String[] args) { Validate.notEmpty("hoge"); Validate.notEmpty(""); } } で、 Exception in thread "main" java.lang.IllegalArgumentException: The vali…

return で値以外も渡す

examples/lisp.g が例になっているようだ >>> import m20090522_yapps200 >>> m20090522_yapps200.parse('expr', "1") ('num', 1) >>> m20090522_yapps200.parse('expr', "1 2") ('num', 1) >>> m20090522_yapps200.parse('expr', "()") [] >>> m20090522_ya…