pep8analysis: update and remove old-style attributes
authorJean Privat <jean@pryen.org>
Wed, 3 Sep 2014 18:04:19 +0000 (14:04 -0400)
committerJean Privat <jean@pryen.org>
Wed, 3 Sep 2014 23:09:09 +0000 (19:09 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

contrib/pep8analysis/src/parser/lexer.nit
contrib/pep8analysis/src/parser/parser.nit
contrib/pep8analysis/src/parser/parser_nodes.nit
contrib/pep8analysis/src/parser/parser_prod.nit
contrib/pep8analysis/src/pep8analysis_web.nit

index f1a3c44..f5b910a 100644 (file)
@@ -6,14 +6,14 @@ intrude import parser_nodes
 private import tables
 
 redef class Token
 private import tables
 
 redef class Token
-    var _text: nullable String
+    var text_cache: nullable String
 
     redef fun text
     do
 
     redef fun text
     do
-        var res = _text
+        var res = _text_cache
         if res != null then return res
         res = location.text
         if res != null then return res
         res = location.text
-       _text = res
+       _text_cache = res
        return res
     end
 
        return res
     end
 
@@ -245,7 +245,7 @@ redef class EOF
 
     init(loc: Location)
     do
 
     init(loc: Location)
     do
-        _text = ""
+        _text_cache = ""
                _location = loc
     end
 end
                _location = loc
     end
 end
@@ -266,25 +266,25 @@ end
 class Lexer
        super TablesCapable
        # Last peeked token
 class Lexer
        super TablesCapable
        # Last peeked token
-       var _token: nullable Token
+       var token: nullable Token
 
        # Lexer current state
 
        # Lexer current state
-       var _state: Int = 0
+       var state: Int = 0
 
        # The source file
 
        # The source file
-       var _file: SourceFile
+       var file: SourceFile
 
        # Current character in the stream
 
        # Current character in the stream
-       var _stream_pos: Int = 0
+       var stream_pos: Int = 0
 
        # Current line number in the input stream
 
        # Current line number in the input stream
-       var _line: Int = 0
+       var line: Int = 0
 
        # Current column in the input stream
 
        # Current column in the input stream
-       var _pos: Int = 0
+       var pos: Int = 0
 
        # Was the last character a cariage-return?
 
        # Was the last character a cariage-return?
-       var _cr: Bool = false
+       var cr: Bool = false
 
        # Constante state values
        private fun state_initial: Int do return 0 end
 
        # Constante state values
        private fun state_initial: Int do return 0 end
index 1c6b68f..4fd6be1 100644 (file)
@@ -23,13 +23,13 @@ end
 class Parser
        super TablesCapable
        # Associated lexer
 class Parser
        super TablesCapable
        # Associated lexer
-       var _lexer: Lexer
+       var lexer: Lexer
 
        # Stack of pushed states and productions
 
        # Stack of pushed states and productions
-       var _stack: Array[State]
+       private var stack: Array[State]
 
        # Position in the stack
 
        # Position in the stack
-       var _stack_pos: Int
+       private var stack_pos: Int
 
        # Create a new parser based on a given lexer
        init(lexer: Lexer)
 
        # Create a new parser based on a given lexer
        init(lexer: Lexer)
@@ -148,10 +148,10 @@ class Parser
                end
        end
 
                end
        end
 
-       var _reduce_table: Array[ReduceAction]
+       private var reduce_table: Array[ReduceAction]
        private fun build_reduce_table
        do
        private fun build_reduce_table
        do
-               _reduce_table = new Array[ReduceAction].with_items(
+               reduce_table = new Array[ReduceAction].with_items(
                        new ReduceAction0(0),
                        new ReduceAction1(0),
                        new ReduceAction2(0),
                        new ReduceAction0(0),
                        new ReduceAction1(0),
                        new ReduceAction2(0),
@@ -194,11 +194,11 @@ end
 redef class Prod
        # Location on the first token after the start of a production
        # So outside the production for epilon production
 redef class Prod
        # Location on the first token after the start of a production
        # So outside the production for epilon production
-       var _first_location: nullable Location
+       var first_location: nullable Location
 
        # Location of the last token before the end of a production
        # So outside the production for epilon production
 
        # Location of the last token before the end of a production
        # So outside the production for epilon production
-       var _last_location: nullable Location
+       var last_location: nullable Location
 end
 
 # Find location of production nodes
 end
 
 # Find location of production nodes
@@ -206,16 +206,16 @@ end
 private class ComputeProdLocationVisitor
        super Visitor
        # Currenlty visited productions that need a first token
 private class ComputeProdLocationVisitor
        super Visitor
        # Currenlty visited productions that need a first token
-       var _need_first_prods: Array[Prod] = new Array[Prod]
+       var need_first_prods: Array[Prod] = new Array[Prod]
 
        # Already visited epsilon productions that waits something after them
 
        # Already visited epsilon productions that waits something after them
-       var _need_after_epsilons: Array[Prod] = new Array[Prod]
+       var need_after_epsilons: Array[Prod] = new Array[Prod]
 
        # Already visited epsilon production that waits something before them
 
        # Already visited epsilon production that waits something before them
-       var _need_before_epsilons: Array[Prod] = new Array[Prod]
+       var need_before_epsilons: Array[Prod] = new Array[Prod]
 
        # Location of the last visited token in the current production
 
        # Location of the last visited token in the current production
-       var _last_location: nullable Location = null
+       var last_location: nullable Location = null
 
        redef fun visit(n: nullable ANode)
        do
 
        redef fun visit(n: nullable ANode)
        do
@@ -305,7 +305,7 @@ private abstract class ReduceAction
                l1.append(l2)
                return l1
        end
                l1.append(l2)
                return l1
        end
-       var _goto: Int
+       var goto: Int
        init(g: Int) do _goto = g
 end
 
        init(g: Int) do _goto = g
 end
 
index e1fb641..97530a4 100644 (file)
@@ -1,16 +1,14 @@
 # Raw AST node hierarchy.
 # This file was generated by SableCC (http://www.sablecc.org/).
 # Raw AST node hierarchy.
 # This file was generated by SableCC (http://www.sablecc.org/).
-module parser_nodes is old_style_init
+module parser_nodes
 
 import location
 
 # Root of the AST hierarchy
 abstract class ANode
 
 import location
 
 # Root of the AST hierarchy
 abstract class ANode
-       var _location: nullable Location = null
-
        # Location is set during AST building. Once built, location cannon be null
        # However, manual instanciated nodes may need mode care
        # Location is set during AST building. Once built, location cannon be null
        # However, manual instanciated nodes may need mode care
-       fun location: Location do return _location.as(not null)
+       var location: Location is writable, noinit
 end
 
 # Ancestor of all tokens
 end
 
 # Ancestor of all tokens
@@ -23,7 +21,6 @@ end
 # Ancestor of all productions
 abstract class Prod
        super ANode
 # Ancestor of all productions
 abstract class Prod
        super ANode
-       fun location=(loc: Location) do _location = loc
 end
 class TEol
        super Token
 end
 class TEol
        super Token
@@ -81,192 +78,130 @@ class TId
 end
 class EOF
        super Token
 end
 class EOF
        super Token
-       #private init noinit do end
 end
 class AError
        super EOF
 end
 class AError
        super EOF
-       #private init noinit do end
 end
 
 class ALine
        super Prod
 end
 
 class ALine
        super Prod
-       var _n_label_decl: nullable ALabelDecl = null
-       fun n_label_decl: nullable ALabelDecl do return _n_label_decl
-    var _n_comment: nullable TComment = null
-    fun n_comment: nullable TComment do return _n_comment
+       var n_label_decl: nullable ALabelDecl = null
+    var n_comment: nullable TComment = null
 end
 class AInstruction
        super Prod
 end
 class AInstruction
        super Prod
-    var _n_id: TId
-    fun n_id: TId do return _n_id
-    fun n_id=(n_id: TId) do _n_id = n_id
-       init do end
+    var n_id: TId is noinit
 end
 class AOperand
        super Prod
 end
 class AOperand
        super Prod
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_value: AValue is noinit
 end
 class AValue super Prod end
 class ADirective super Prod end
 
 class AListing
        super Prod
 end
 class AValue super Prod end
 class ADirective super Prod end
 
 class AListing
        super Prod
-    var _n_lines: List[ALine] = new List[ALine]
-    fun n_lines: List[ALine] do return _n_lines
-    var _n_label_decl: nullable ALabelDecl = null
-    fun n_label_decl: nullable ALabelDecl do return _n_label_decl
-    var _n_end_block: TEndBlock
-    fun n_end_block: TEndBlock do return _n_end_block
-       init do end
+    var n_lines: List[ALine] = new List[ALine]
+    var n_label_decl: nullable ALabelDecl = null
+    var n_end_block: TEndBlock is noinit
 end
 class AEmptyLine
        super ALine
 end
 class AEmptyLine
        super ALine
-    var _n_eol: TEol
-    fun n_eol: TEol do return _n_eol
-       init do end
+    var n_eol: TEol is noinit
 end
 abstract class ANonEmptyLine
        super ALine
 end
 class AInstructionLine
        super ANonEmptyLine
 end
 abstract class ANonEmptyLine
        super ALine
 end
 class AInstructionLine
        super ANonEmptyLine
-    var _n_instruction: AInstruction
-    fun n_instruction: AInstruction do return _n_instruction
-    var _n_eol: TEol
-    fun n_eol: TEol do return _n_eol
-       init do end
+    var n_instruction: AInstruction is noinit
+    var n_eol: TEol is noinit
 end
 class ADirectiveLine
        super ANonEmptyLine
 end
 class ADirectiveLine
        super ANonEmptyLine
-    var _n_directive: ADirective
-    fun n_directive: ADirective do return _n_directive
-    var _n_eol: TEol
-    fun n_eol: TEol do return _n_eol
-       init do end
+    var n_directive: ADirective is noinit
+    var n_eol: TEol is noinit
 end
 class ALabelDecl
        super Prod
 end
 class ALabelDecl
        super Prod
-    var _n_id: TId
-    fun n_id: TId do return _n_id
-    var _n_colon: TColon
-    fun n_colon: TColon do return _n_colon
-       init do end
+    var n_id: TId is noinit
+    var n_colon: TColon is noinit
 end
 class AUnaryInstruction
        super AInstruction
 end
 class ABinaryInstruction
        super AInstruction
 end
 class AUnaryInstruction
        super AInstruction
 end
 class ABinaryInstruction
        super AInstruction
-    var _n_operand: AOperand
-    fun n_operand: AOperand do return _n_operand
-       init do end
+    var n_operand: AOperand is noinit
 end
 class AImmediateOperand
        super AOperand
 end
 class AAnyOperand
        super AOperand
 end
 class AImmediateOperand
        super AOperand
 end
 class AAnyOperand
        super AOperand
-    var _n_comma: TComma
-    fun n_comma: TComma do return _n_comma
-    var _n_id: TId
-    fun n_id: TId do return _n_id
-       init do end
+    var n_comma: TComma is noinit
+    var n_id: TId is noinit
 end
 class ALabelValue
        super AValue
 end
 class ALabelValue
        super AValue
-    var _n_id: TId
-    fun n_id: TId do return _n_id
-       init do end
+    var n_id: TId is noinit
 end
 class ANumberValue
        super AValue
 end
 class ANumberValue
        super AValue
-    var _n_number: TNumber
-    fun n_number: TNumber do return _n_number
-       init do end
+    var n_number: TNumber is noinit
 end
 class ACharValue
        super AValue
 end
 class ACharValue
        super AValue
-    var _n_char: TChar
-    fun n_char: TChar do return _n_char
-       init do end
+    var n_char: TChar is noinit
 end
 class AStringValue
        super AValue
 end
 class AStringValue
        super AValue
-    var _n_string: TString
-    fun n_string: TString do return _n_string
-       init do end
+    var n_string: TString is noinit
 end
 class AHexValue
        super AValue
 end
 class AHexValue
        super AValue
-    var _n_hex: THex
-    fun n_hex: THex do return _n_hex
-       init do end
+    var n_hex: THex is noinit
 end
 class AByteDirective
        super ADirective
 end
 class AByteDirective
        super ADirective
-    var _n_tk_byte: TTkByte
-    fun n_tk_byte: TTkByte do return _n_tk_byte
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_byte: TTkByte is noinit
+    var n_value: AValue is noinit
 end
 class AWordDirective
        super ADirective
 end
 class AWordDirective
        super ADirective
-    var _n_tk_word: TTkWord
-    fun n_tk_word: TTkWord do return _n_tk_word
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_word: TTkWord is noinit
+    var n_value: AValue is noinit
 end
 class ABlockDirective
        super ADirective
 end
 class ABlockDirective
        super ADirective
-    var _n_tk_block: TTkBlock
-    fun n_tk_block: TTkBlock do return _n_tk_block
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_block: TTkBlock is noinit
+    var n_value: AValue is noinit
 end
 class AAsciiDirective
        super ADirective
 end
 class AAsciiDirective
        super ADirective
-    var _n_tk_ascii: TTkAscii
-    fun n_tk_ascii: TTkAscii do return _n_tk_ascii
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_ascii: TTkAscii is noinit
+    var n_value: AValue is noinit
 end
 class AAddrssDirective
        super ADirective
 end
 class AAddrssDirective
        super ADirective
-    var _n_tk_addrss: TTkAddrss
-    fun n_tk_addrss: TTkAddrss do return _n_tk_addrss
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_addrss: TTkAddrss is noinit
+    var n_value: AValue is noinit
 end
 class AEquateDirective
        super ADirective
 end
 class AEquateDirective
        super ADirective
-    var _n_tk_equate: TTkEquate
-    fun n_tk_equate: TTkEquate do return _n_tk_equate
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_equate: TTkEquate is noinit
+    var n_value: AValue is noinit
 end
 class ABurnDirective
        super ADirective
 end
 class ABurnDirective
        super ADirective
-    var _n_tk_burn: TTkBurn
-    fun n_tk_burn: TTkBurn do return _n_tk_burn
-    var _n_value: AValue
-    fun n_value: AValue do return _n_value
-       init do end
+    var n_tk_burn: TTkBurn is noinit
+    var n_value: AValue is noinit
 end
 
 class Start
        super Prod
 end
 
 class Start
        super Prod
-    var _n_base: nullable AListing
-    fun n_base: nullable AListing do return _n_base
-    var _n_eof: EOF
-    fun n_eof: EOF do return _n_eof
+    var n_base: nullable AListing
+    var n_eof: EOF is noinit
        init(n_base: nullable AListing, n_eof: EOF)
        do
                super
        init(n_base: nullable AListing, n_eof: EOF)
        do
                super
index 8f71631..f7fb2f7 100644 (file)
@@ -8,9 +8,7 @@ private import tables
 
 redef class ANode
        # Parent of the node in the AST
 
 redef class ANode
        # Parent of the node in the AST
-       var _parent: nullable ANode
-       fun parent: nullable ANode do return _parent
-       fun parent=(p: nullable ANode) do _parent = p
+       var parent: nullable ANode is writable
 
        # Remove a child from the AST
        fun remove_child(child: ANode)
 
        # Remove a child from the AST
        fun remove_child(child: ANode)
index 6167d47..30c0849 100644 (file)
@@ -31,6 +31,7 @@ import ast
 import model
 import cfg
 import flow_analysis
 import model
 import cfg
 import flow_analysis
+intrude import standard::stream
 
 in "C++" `{
        #include <bind.h>
 
 in "C++" `{
        #include <bind.h>