コマンドラインオプション

ソースコードファイル (*.ring) または、オブジェクトファイル (*.ringo) とオプションを指定するとプログラムを実行します。

書式:

ring <ファイル名.ring>|<ファイル名.ringo> [オプション]

オプション:

オプション

説明

-tokens

ソースコードファイルのトークンリストを表示します。

-rules

トークンに適用された文法規則を表示します。

-ic

中間バイトコードを表示します (実行前)。

-icfinal

最終バイトコードを表示します (実行後)。

-cgi

エラーメッセージの前に http レスポンスヘッダを表示します。

-norun

コンパイル後にプログラムを実行しません。

-ins

実行前に命令演算コードを表示します。

-performance

プログラムの実行前後に処理時間測定結果を表示します。

-go

オブジェクトファイルを生成します。

-geo

組み込み型オブジェクトファイル (C ソースコード) を生成します。

-w

警告を表示します。

注釈

オブジェクトファイル形式では、一部使用できないオプションがあります。

トークンの表示

用例:

Func Main
        See "Hello World" + nl
        for x = 1 to 10
                see x + nl
        next
        test()

func test
        see "welcome" + nl
        o1 = new point { x=10 y=20 z=30 }
        see o1

class point x y z

コマンド:

ring test.ring -tokens -norun

実行結果:

===================================================
Tokens - Generated by the Scanner
===================================================

   Keyword : FUNC
Identifier : main
   EndLine
   Keyword : SEE
   Literal : Hello World
  Operator : +
Identifier : nl
   EndLine
   Keyword : FOR
Identifier : x
  Operator : =
    Number : 1
   Keyword : TO
    Number : 10
   EndLine
   Keyword : SEE
Identifier : x
  Operator : +
Identifier : nl
   EndLine
   Keyword : NEXT
   EndLine
Identifier : test
  Operator : (
  Operator : )
   EndLine
   Keyword : FUNC
Identifier : test
   EndLine
   Keyword : SEE
   Literal : welcome
  Operator : +
Identifier : nl
   EndLine
Identifier : o1
  Operator : =
   Keyword : NEW
Identifier : point
  Operator : {
Identifier : x
  Operator : =
    Number : 10
Identifier : y
  Operator : =
    Number : 20
Identifier : z
  Operator : =
    Number : 30
  Operator : }
   EndLine
   Keyword : SEE
Identifier : o1
   EndLine
   Keyword : CLASS
Identifier : point
Identifier : x
Identifier : y
Identifier : z
   EndLine

===================================================

文法規則の表示

コマンド:

ring test.ring -rules -norun

実行結果:

===================================================
Grammar Rules Used by The Parser
===================================================

Rule : Program --> {Statement}

Line 1
Rule : Statement  --> 'Func' Identifier [ParaList]

Line 2
Rule : Factor --> Literal
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Arithmetic --> Arithmetic + Arithmetic
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'See' Expr

Line 3
Rule : Factor --> Number
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Factor --> Number
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'For' Identifier '=' Expr to Expr ['step' Expr]

Line 4
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Arithmetic --> Arithmetic + Arithmetic
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'See' Expr

Line 5
Rule : Next --> 'Next'

Line 6
Rule : Mixer -> '(' [Expr { ',' Expr} ] ')'

Line 8
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : Statement  --> 'Func' Identifier [ParaList]

Line 9
Rule : Factor --> Literal
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : Arithmetic --> Arithmetic + Arithmetic
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'See' Expr

Line 10
Rule : Factor --> New Identifier {'.' Identifier }
Rule : Mixer --> '{' {Statement} BraceEnd
Rule : Factor --> Number
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Assignment -> '=' Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : Factor --> Number
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Assignment -> '=' Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : Factor --> Number
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Assignment -> '=' Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : BraceEnd --> '}'
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Assignment -> '=' Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr

Line 11
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> 'See' Expr

Line 13
Rule : Statement  --> 'Class' Identifier
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr
Rule : Factor --> Identifier [ {Mixer} | Assignment | PlusPlus | MinusMinus]
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR -->  BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement  --> Expr

===================================================

中間コードの表示

コマンド:

ring test.ring -ic -norun

実行結果:

===================================================
Byte Code - Before Execution by the VM
===================================================

         PC      OPCode        Data

          1  ReturnNull
          2        Func    main
          3     NewLine       2
          4     FuncExE
          5       PushC   Hello World
          6       LoadA      nl      0
          7       PushV
          8         SUM       0
          9       Print
         10     NewLine       3
         11    ExitMark      29     28
         12  LoadAFirst       x
         13       PushN   1.000000
         14  BeforeEqual       0
         15  Assignment
         16       PushN   1.000000
         17  StepNumber
         18  JumpVarLENum       x  10.000000    29
         19     NewLine       4
         20     FuncExE
         21       LoadA       x      0
         22       PushV
         23       LoadA      nl      0
         24       PushV
         25         SUM       0
         26       Print
         27     NewLine       5
         28     IncJump       x     18
         29  POPExitMark
         30     POPStep
         31     NewLine       6
         32    LoadFunc    test
         33        Call       0
         34  NoOperation
         35     NewLine       8
         36       PushV
         37   FreeStack
         38  ReturnNull
         39        Func    test
         40     NewLine       9
         41     FuncExE
         42       PushC   welcome
         43       LoadA      nl      0
         44       PushV
         45         SUM       0
         46       Print
         47     NewLine      10
         48       LoadA      o1      0
         49  AssignmentPointer
         50         New   point
         51    SetScope
         52       PushV
         53  BraceStart
         54       LoadA       x      0     58
         55  AssignmentPointer
         56       PushN   10.000000
         57  BeforeEqual       0
         58  Assignment       0      0
         59   FreeStack
         60       LoadA       y      0     64
         61  AssignmentPointer
         62       PushN   20.000000
         63  BeforeEqual       0
         64  Assignment       0      0
         65   FreeStack
         66       LoadA       z      0     70
         67  AssignmentPointer
         68       PushN   30.000000
         69  BeforeEqual       0
         70  Assignment       0      0
         71   FreeStack
         72    LoadFunc   ismethod
         73       LoadA    self      0
         74       PushV
         75       PushC   braceend
         76        Call
         77  NoOperation
         78       PushV
         79       JumpZ      85
         80    LoadFunc   braceend
         81        Call
         82  NoOperation
         83       PushV
         84   FreeStack
         85    BraceEnd
         86   FreeStack
         87     NewLine      11
         88     FuncExE
         89       LoadA      o1      0
         90       PushV
         91       Print
         92     NewLine      13
         93  ReturnNull
         94       Class   point  006E8BC0
         95    NewLabel
         96       LoadA       x      0
         97       PushV
         98   FreeStack
         99       LoadA       y      0
        100       PushV
        101   FreeStack
        102       LoadA       z      0
        103       PushV
        104   FreeStack
        105  ReturnNull

===================================================

最終中間コードの表示

コマンド:

ring test.ring -icfinal

実行結果:

Hello World
1
2
3
4
5
6
7
8
9
10
welcome
x: 10.000000
y: 20.000000
z: 30.000000


===================================================
Byte Code - After Execution by the VM
===================================================

         PC      OPCode        Data

          1  ReturnNull
          2        Func    main
          3     NewLine       2
          4     FuncExE
          5       PushC   Hello World
          6       PushP   007D3670      0
          7       PushV
          8         SUM       0
          9       Print
         10     NewLine       3
         11    ExitMark      29     28
         12  LoadAFirst       x
         13       PushN   1.000000
         14  BeforeEqual       0
         15  Assignment
         16       PushN   1.000000
         17  StepNumber
         18  JumpVarLPLENum       x  10.000000    29
         19     NewLine       4
         20     FuncExE
         21  PushPLocal       x      0
         22       PushV
         23       PushP   007D3670      0
         24       PushV
         25         SUM       0
         26       Print
         27     NewLine       5
         28   IncLPJump       x     18
         29  POPExitMark
         30     POPStep
         31     NewLine       6
         32   LoadFuncP    test
         33        Call       0
         34  NoOperation
         35     NewLine       8
         36       PushV
         37   FreeStack
         38  ReturnNull
         39        Func    test
         40     NewLine       9
         41     FuncExE
         42       PushC   welcome
         43       PushP   007D3670      0
         44       PushV
         45         SUM       0
         46       Print
         47     NewLine      10
         48  PushPLocal      o1      0
         49  AssignmentPointer
         50         New   point
         51    SetScope
         52       PushV
         53  BraceStart
         54       LoadA       x      0     58
         55  AssignmentPointer
         56       PushN   10.000000
         57  BeforeEqual       0
         58  SetProperty       0    106
         59   FreeStack
         60       LoadA       y      0     64
         61  AssignmentPointer
         62       PushN   20.000000
         63  BeforeEqual       0
         64  SetProperty       0    141
         65   FreeStack
         66       LoadA       z      0     70
         67  AssignmentPointer
         68       PushN   30.000000
         69  BeforeEqual       0
         70  SetProperty       0    176
         71   FreeStack
         72    LoadFunc   ismethod
         73       LoadA    self      0
         74       PushV
         75       PushC   braceend
         76        Call
         77  NoOperation
         78       PushV
         79       JumpZ      85
         80    LoadFunc   braceend
         81        Call
         82  NoOperation
         83       PushV
         84   FreeStack
         85    BraceEnd
         86   FreeStack
         87     NewLine      11
         88     FuncExE
         89  PushPLocal      o1      0
         90       PushV
         91       Print
         92     NewLine      13
         93  ReturnNull
         94       Class   point  007D8470
         95    NewLabel
         96       LoadA       x      0
         97       PushV
         98   FreeStack
         99       LoadA       y      0
        100       PushV
        101   FreeStack
        102       LoadA       z      0
        103       PushV
        104   FreeStack
        105  ReturnNull
        106    LoadFunc   ismethod
        107       LoadA   ring_gettemp_var      0
        108       PushV
        109       PushC    setx
        110        Call       0
        111  NoOperation
        112       PushV
        113       JumpZ     132
        114     NewLine       2
        115       LoadA   ring_gettemp_var      0
        116  LoadMethod    setx
        117       LoadA   ring_settemp_var      0
        118       PushV
        119        Call       0      1
        120  AfterCallMethod
        121       PushV
        122   FreeStack
        123     NewLine       3
        124       LoadA   ring_tempflag_var      0    128
        125  AssignmentPointer
        126       PushN   0.000000
        127  BeforeEqual       0
        128  Assignment       0      0
        129   FreeStack
        130     NewLine       4
        131        Jump     140
        132     NewLine       5
        133       PushP   007D37D8      0    137
        134  AssignmentPointer
        135       PushN   1.000000
        136  BeforeEqual       0
        137  Assignment       0      0
        138   FreeStack
        139     NewLine       6
        140      Return
        141    LoadFunc   ismethod
        142       LoadA   ring_gettemp_var      0
        143       PushV
        144       PushC    sety
        145        Call       0
        146  NoOperation
        147       PushV
        148       JumpZ     167
        149     NewLine       2
        150       LoadA   ring_gettemp_var      0
        151  LoadMethod    sety
        152       LoadA   ring_settemp_var      0
        153       PushV
        154        Call       0      1
        155  AfterCallMethod
        156       PushV
        157   FreeStack
        158     NewLine       3
        159       LoadA   ring_tempflag_var      0    163
        160  AssignmentPointer
        161       PushN   0.000000
        162  BeforeEqual       0
        163  Assignment       0      0
        164   FreeStack
        165     NewLine       4
        166        Jump     175
        167     NewLine       5
        168       PushP   007D37D8      0    172
        169  AssignmentPointer
        170       PushN   1.000000
        171  BeforeEqual       0
        172  Assignment       0      0
        173   FreeStack
        174     NewLine       6
        175      Return
        176    LoadFunc   ismethod
        177       LoadA   ring_gettemp_var      0
        178       PushV
        179       PushC    setz
        180        Call       0
        181  NoOperation
        182       PushV
        183       JumpZ     202
        184     NewLine       2
        185       LoadA   ring_gettemp_var      0
        186  LoadMethod    setz
        187       LoadA   ring_settemp_var      0
        188       PushV
        189        Call       0      1
        190  AfterCallMethod
        191       PushV
        192   FreeStack
        193     NewLine       3
        194       LoadA   ring_tempflag_var      0    198
        195  AssignmentPointer
        196       PushN   0.000000
        197  BeforeEqual       0
        198  Assignment       0      0
        199   FreeStack
        200     NewLine       4
        201        Jump     210
        202     NewLine       5
        203       PushP   007D37D8      0    207
        204  AssignmentPointer
        205       PushN   1.000000
        206  BeforeEqual       0
        207  Assignment       0      0
        208   FreeStack
        209     NewLine       6
        210      Return

===================================================

CGI への対応

コマンド:

ring test.ring -cgi

コンパイルの実行

コマンド:

ring test.ring -norun

命令演算コードの表示

コマンド:

ring test.ring -ins

実行結果:

===================================================

Operation  : ReturnNull
PC         : 1
Line Number    : 1  , File test.ring

SP (After) : 0  - FuncSP : 0
 LineNumber 1
===================================================
.....
.....
.....
(以下、長文のため省略)

実行性能の計測

コマンド:

ring test.ring -performance

実行結果:

===================================================
Date  : 2015/09/15 Time : 15:56:17
Clock : 0
===================================================
Hello World
1
2
3
4
5
6
7
8
9
10
welcome
x: 10.000000
y: 20.000000
z: 30.000000

===================================================
Date  : 2015/09/15 Time : 15:56:17
Clock : 0
===================================================

オブジェクトファイルの生成

-go オプションは、ソースコードファイル (*.ring) からオブジェクトファイル (*.ringo) を生成します。

ちなみに

アプリケーション (商用またはオープンソース) の Ring ソースファイル一式を非公開 (保管) または配布できます。 また、アプリケーションの配布または実行用のオブジェクトファイルも生成できます。

コマンド:

ring test.ring -go

コンパイル済みのオブジェクトファイルを実行するには、

ring test.ringo

組み込み型オブジェクトファイルの生成

-geo オプションはソースコードファイル (*.ring) から組み込み型オブジェクトファイル (C ソースコード) を生成します。

コマンド:

ring test.ring -geo

このコマンドは最低でも以下のファイルを生成します。

test.c
ringappcode.c
ringappcode.h

プロジェクトの規模により、それ以上のファイルを生成します。

生成後のファイルは Ring VM のバイトコードとして実行されます。