2008-04-01から1ヶ月間の記事一覧
require 'pdf/simpletable' pdf = PDF::Writer.new PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.header_gap tab.header_gap = 200 tab.show_lines = :all data = [] 80.times do |i| data << { "col1" => "#{i}", "col2" =>…
Java FAQ:S011 Q-07 class C2008042001 { void foo() { System.out.println("foo in C2008042001"); } } class C2008042002 extends C2008042001 { C2008042002() { super.foo(); foo(); } void foo() { System.out.println("foo in C2008042002"); } } pub…
「yacc.parse(s, lexer = Lexer())」 #!/usr/bin/env python tokens = ( 'A', 'B', 'C', ) class LexToken: def __init__(self, t, value, lineno, lexpos): self.type = t self.value = value self.lineno = lineno self.lexpos = lexpos class Lexer: def …
require 'pdf/simpletable' pdf = PDF::Writer.new PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.split_rows tab.split_rows = true tab.row_gap = 150 tab.show_lines = :all data = [ { "col1" => "foo", "col2" => "bar",…
Java FAQ:S011 Q-06まんま class C2008041901 { static int foo() { return 1; } static void bar() { System.out.println("foo() = " + foo()); } } public class C2008041900 extends C2008041901 { static int foo() { return 2; } public static void m…
「yacc.yacc(method="SLR")」 #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', 'C', ) t_A = r'A' t_B = r'B' t_C = r'C' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() imp…
何?
Java FAQ:S010 Q-10 class C2008041801 { int x; C2008041801(int x) { this.x = x; } } class C2008041802 extends C2008041801 { int y; C2008041802() { super(this.y); } } public class C2008041800 { public static void main(String[] args) { new C…
まんま #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', 'C', 'D', 'X', ) t_A = r'A' t_B = r'B' t_C = r'C' t_D = r'D' t_X = r'X' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) le…
require 'pdf/simpletable' pdf = PDF::Writer.new def table(pdf) PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.minimum_space tab.minimum_space = 500 tab.row_gap = 50 tab.show_lines = :all data = [ { "col1" => "foo…
Java FAQ:S010 Q-09ほぼ、まんま abstract class C2008041701 { C2008041701() { show(); } abstract public void show(); } class C2008041702 extends C2008041701 { String name; C2008041702(String name) { this.name = name; } public void show() { …
自分で書き下す必要があるようだほぼ、まんま #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', 'C', 'D', ) t_A = r'A' t_B = r'B' t_C = r'C' t_D = r'D' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0…
require 'pdf/simpletable' pdf = PDF::Writer.new PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.row_gap tab.row_gap = 50 tab.show_lines = :all data = [ { "col1" => "foo", "col2" => "bar", "col3" => "baz" }, ] tab.…
Java FAQ:S010 Q-08ほぼ、まんま class C2008041601 { int a; C2008041601() { this.a = 1; } } class C2008041602 extends C2008041601 { int a = 10; C2008041602() { System.out.println(this.a); } } public class C2008041600 { public static void ma…
#!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', 'C', ) t_A = r'A' t_B = r'B' t_C = r'C' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() import ply.yacc as yacc def p_i…
require 'pdf/simpletable' pdf = PDF::Writer.new def table(pdf, maximum_width) PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.maximum_width tab.maximum_width = maximum_width if maximum_width tab.show_lines = :all …
Java FAQ:S010 Q-04ほぼ、まんま class C2008041501 { private static C2008041501 instance = new C2008041501(); private C2008041501() { } public static C2008041501 getInstance() { return instance; } } public class C2008041500 { public static …
良く分かっていない #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', ) t_A = r'A' t_B = r'B' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() import ply.yacc as yacc def …
require 'pdf/simpletable' pdf = PDF::Writer.new def table(pdf, width) PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.width tab.width = width if width tab.show_lines = :all data = [ { "col1" => "foo foo foo foo fo…
Java FAQ:S010 Q-03話がちょっとややこしい? と、思ったのは、デフォルトコンストラクタを勘違いしていたからのようだ。「クラスの定義にコンストラクタを一つも記述しなかった場合、コンパイラによって自動的に引数なしのコンストラクタが生成されます。…
試したが、失敗…(原因不明) #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', ) t_A = r'A' t_ignore = " \t" literals = ['+', '<'] def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() import ply.yacc…
require 'pdf/simpletable' pdf = PDF::Writer.new def table(pdf, orientation) PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.orientation tab.orientation = orientation tab.show_lines = :all data = [ { "col1" => "foo…
Java FAQ:S010 Q-02なんでそういう仕様なんだっけ?C++ も同じかな? class C2008041301 { C2008041301() { System.out.println("C2008041301"); } } class C2008041302 extends C2008041301 { C2008041302() { System.out.println("C2008041302"); } } pub…
#!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', ) t_A = r'A' t_B = r'B' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() import ply.yacc as yacc def p_input(p): 'input …
require 'pdf/simpletable' pdf = PDF::Writer.new def table(pdf, position) PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.position tab.position = position tab.show_lines = :all data = [ { "col1" => "foo", "col2" =>…
Java FAQ:S010 Q-01 public class C2008041200 { } をコンパイルした後、javap -c を実行 Compiled from C2008041200.java public class C2008041200 extends java.lang.Object { public C2008041200(); } Method C2008041200() 0 aload_0 1 invokespecial …
example/calc/calc.py を実行すると、parser.out, parsetab.py というものが生成されるparser.out Unused terminals: Grammar Rule 1 statement -> NAME = expression Rule 2 statement -> expression Rule 3 expression -> expression + expression Rule 4 …
require 'pdf/simpletable' pdf = PDF::Writer.new PDF::SimpleTable.new do |tab| tab.column_order = %w(col1 col2 col3) p tab.title_gap tab.title_gap = 50 tab.title = "TITLE" tab.show_lines = :all data = [ { "col1" => "foo", "col2" => "bar", "…
Java FAQ:S008 Q-13 public class C2008041100 { public static void main(String[] args) { String s1 = "abc"; String s2 = new StringBuffer("abc").toString(); System.out.println(s1 == s2); System.out.println(s1.equals(s2)); System.out.println(…
start で指定 #!/usr/bin/env python import ply.lex as lex tokens = ( 'A', 'B', ) t_A = r'A' t_B = r'B' t_ignore = " \t" def t_error(t): print "Illegal character '%s'" % t.value[0] t.lexer.skip(1) lex.lex() import ply.yacc as yacc start = 'i…