Function list for Monkey language.

Function list for Monkey language.

2
NewbieNewbie
2

    Sep 21, 2011#1

    Hellou,

    i have created syntax highlighting for Monkey language, and now i want make function list view with structure:
    Import
    Globals
    Classes
    - Fields
    - Methods
    Functions
    .

    I have define this here:

    Code: Select all

    /TGBegin "Classes"
    	
    	/TGFindStr = "%Class^([ ^t]+[a-z_0-9.*]+^)"					
    	/TGFindBStart = "Class"
    	/TGFindBEnd = "End Class"	
    	
    	/TGBegin "Fields"
    		/TGFindStr = "[ ^t]Field[ ^t]"	
    	/TGEnd		
    	
    	/TGBegin "Methods"
    		/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    		/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    		/TGFindStr = "[ ^t]++Method[ ^t]++New++"
    		/TGBegin "Argument"
    			/TGFindStr = "[ ^t^p]++^([~,]+^)"
    			/TGFindBStart = "("
    			/TGFindBEnd = ")"		
    		/TGEnd
    		/TGBegin "Return"
    				/TGFindStr = "^([a-z]+^)"
    				/TGFindBStart = "Return"
    				/TGFindBEnd = "End"
    			/TGEnd
    	/TGEnd
    /TGEnd
    
    
    /TGBegin "Function"
    	/TGFindStr = "[ ^t]++Function[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    	/TGFindStr = "[ ^t]++Function[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    	/TGBegin "Argument"
    		/TGFindStr = "[ ^t^p]++^([~,]+^)"
    		/TGFindBStart = "("
    		/TGFindBEnd = ")"		
    	/TGEnd
    	/TGBegin "Return"
    			/TGFindStr = "^([a-z]+^)"
    			/TGFindBStart = "Return"
    			/TGFindBEnd = "End"
    		/TGEnd
    /TGEnd
    
    Maybe is something is wrong because, group Fields and Methods doesn't work and are not included under Group "classes", when i use:

    Code: Select all

    
    /TGBegin "Fields"
    	/TGFindStr = "[ ^t]Field[ ^t]"	
    /TGEnd	
    
    /TGBegin "Methods"
    	/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    	/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    	/TGFindStr = "[ ^t]++Method[ ^t]++New++"
    	/TGBegin "Argument"
    		/TGFindStr = "[ ^t^p]++^([~,]+^)"
    		/TGFindBStart = "("
    		/TGFindBEnd = ")"		
    	/TGEnd
    	/TGBegin "Return"
    			/TGFindStr = "^([a-z]+^)"
    			/TGFindBStart = "Return"
    			/TGFindBEnd = "End"
    		/TGEnd
    /TGEnd
    
    out of group class, then all fields and methods are correctly readed.

    Wordfile:

    Code: Select all

    /L15"MONKEY" MONKEY_LANG Line Comment = ' Block Comment On = #Rem Block Comment Off = #End Escape Char = \ File Extensions = MONKEY
    /TGBegin "Global"
    /TGFindStr = "%Global[ ^t]"
    /TGEnd
    /TGBegin "Local"
    /TGFindStr = "%Local[ ^t]"
    /TGEnd
    /TGBegin "Import"
    /TGFindStr = "%Import^([ ^t]+[a-z0-9.*]+^)"
    /TGEnd
    
    /TGBegin "Classes"
    	
    	/TGFindStr = "%Class^([ ^t]+[a-z_0-9.*]+^)"					
    	/TGFindBStart = "Class"
    	/TGFindBEnd = "End Class"	
    	
    	/TGBegin "Fields"
    		/TGFindStr = "[ ^t]Field[ ^t]"	
    	/TGEnd		
    	
    	/TGBegin "Methods"
    		/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    		/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    		/TGFindStr = "[ ^t]++Method[ ^t]++New++"
    		/TGBegin "Argument"
    			/TGFindStr = "[ ^t^p]++^([~,]+^)"
    			/TGFindBStart = "("
    			/TGFindBEnd = ")"		
    		/TGEnd
    		/TGBegin "Return"
    				/TGFindStr = "^([a-z]+^)"
    				/TGFindBStart = "Return"
    				/TGFindBEnd = "End"
    			/TGEnd
    	/TGEnd
    /TGEnd
    
    /TGBegin "Fields"
    	/TGFindStr = "[ ^t]Field[ ^t]"	
    /TGEnd	
    
    /TGBegin "Methods"
    	/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    	/TGFindStr = "[ ^t]++Method[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    	/TGFindStr = "[ ^t]++Method[ ^t]++New++"
    	/TGBegin "Argument"
    		/TGFindStr = "[ ^t^p]++^([~,]+^)"
    		/TGFindBStart = "("
    		/TGFindBEnd = ")"		
    	/TGEnd
    	/TGBegin "Return"
    			/TGFindStr = "^([a-z]+^)"
    			/TGFindBStart = "Return"
    			/TGFindBEnd = "End"
    		/TGEnd
    /TGEnd
    
    /TGBegin "Function"
    	/TGFindStr = "[ ^t]++Function[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)"
    	/TGFindStr = "[ ^t]++Function[ ^t]++^([a-z_][a-z_0-9]++:[a-z_^~][a-z_0-9]++^)"
    	/TGBegin "Argument"
    		/TGFindStr = "[ ^t^p]++^([~,]+^)"
    		/TGFindBStart = "("
    		/TGFindBEnd = ")"		
    	/TGEnd
    	/TGBegin "Return"
    			/TGFindStr = "^([a-z]+^)"
    			/TGFindBStart = "Return"
    			/TGFindBEnd = "End"
    		/TGEnd
    /TGEnd
    
    /Colors = 12632256,4259584,16711680,16744448,16711935,
    /Colors Back = 16777215,16777215,16777215,16777215,16777215,
    /Colors Auto Back = 1,1,1,1,1,
    /Font Style = 0,1,1,0,0,
    /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> ,	.?
    /Member String = "^([A-Za-z0-9_:.]+^)[ ^t*&]+$S[ ^t]++[(=);,]"
    /Variable String = "^([A-Za-z0-9_:.]+^)[ ^t*&]+$S[ ^t]++[(=);,]"
    /Indent Strings = "{"
    /Unindent Strings = "}"
    /Open Brace Strings =  "("
    /Close Brace Strings = ")"
    /Open Fold Strings = "Function" "Method" "Class"
    /Close Fold Strings = "End Function" "End Method" "End Class"
    /C1"Keywords" STYLE_KEYWORD Colors = 33023 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 1
    #End
    #Else
    #If
    #Rem
    Abstract
    Bool
    Case
    Class
    Else
    ElseIf
    End
    Endif
    Extends
    Extern
    False
    Field
    Float
    For
    Function
    Global
    If
    Import
    Int
    Local
    Method
    Next
    New
    Private
    Public
    Repeat
    Return
    Select
    Self
    Step
    Strict
    String
    Then
    To
    True
    Void
    WEnd
    /C2"Classes" STYLE_FUNCTION Colors = 8421440 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 1
    Abs
    AccelX
    AccelY
    AccelZ
    ACos
    AddFirst
    AddLast
    ASin
    ATan
    ATan2
    Ceil
    Clamp
    Class
    Cls
    Const
    Contains
    Cos
    DeviceHeight
    DeviceWidth
    DrawCircle
    DrawEllipse
    DrawImage
    DrawImageRect
    DrawLine
    DrawOval
    DrawRect
    DrawText
    Eachin
    EndsWith
    Error
    Find
    FindLast
    Floor
    FromChar
    Function
    Get
    GetAlpha
    GetBlend
    GetColor
    GetFont
    GetChar
    GetMatrix
    GetScissor
    GrabImage
    ChannelState
    Join
    JoyDown
    JoyHit
    KeyDown
    KeyHit
    Length
    LoadImage
    LoadSound
    LoadState
    LoadString
    Log
    Max
    Method
    Millisecs
    Min
    MouseDown
    MouseHit
    MouseX
    MouseY
    PlaySound
    PopMatrix
    Pow
    PushMatrix
    Remove
    RemoveEach
    Replace
    Rnd
    Rotate
    SaveState
    Scale
    Select
    SetAlpha
    SetBlend
    SetColor
    SetFont
    SetHandle
    SetChannelPan
    SetChannelRate
    SetChannelVolume
    SetMatrix
    SetScissor
    SetUpdateRate
    Sgn
    Shl
    Shr
    Sin
    Split
    Sqrt
    StartsWith
    StopChannel
    Tan
    TouchDown
    TouchHit
    TouchX
    TouchY
    Transform
    Translate
    Until
    ValueForKey
    Wend
    While
    /C3"Operators" STYLE_OPERATOR Colors = 33023 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
    !
    %
    &
    *
    +
    -
    // /
    <
    =
    >
    ^
    |
    ~
    /C4"Braces, comma, semicolon" Colors = 16777215 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 1
    (
    )
    ,
    ;
    [
    ]
    {
    }
    
    Test file:

    Code: Select all

    Strict 
    Import mojo
    Import agfx
    
    Function CreateFlashArrayFromFile:FlashArray<b2Vec2>(filename:String)
    	Local res:FlashArray<b2Vec2>= New FlashArray<b2Vec2>()
    	Local file:String = LoadString("shapes/"+filename)
    	
    	If file.Length()=0 Then Error("Shape file: .data/shapes/"+filename+" doesn't exist!")
    	Local verts:String[] = file.Split("|")
    	For Local i:Int=0 to verts.Length()-1
    		Local coord:String[]=verts[i].Split(",")
    		Local x:Float = Float(coord[0])
    		Local y:Float = Float(coord[1])
    		res.Push(New b2Vec2(x,y))
    	Next
    	Return res
    End Function
    
    Class TPivot Extends TEntity
    	
    	
    	Field offset:TVector2 
    	
    	'|--------------------------------------------------------------------------------
    	'| Constructor
    	'|--------------------------------------------------------------------------------
    	Method New(n:String,x:Float=0, y:Float=0,w:Int=32,h:Int=32)
    	
    		Self.name = n
    		Self.speed = 1.0
    		Self.position.Set(x,y)	
    		Self.size.Set(w,h)
    		Self.visible = True
    		Self.rotation = 0
    		Self.radius = w/2
    		Self.offset = New TVector2(0,0)
    		Self.velocity = New TVector2(0,0)
    		Self.collision.Set(Self.position,Self.size,Self.radius)
    	End Method
    	
    	'|--------------------------------------------------------------------------------
    	'| UPDATE
    	'|--------------------------------------------------------------------------------
    	Method Update:Void()	
    		Self.collision.UpdateByCenter(Self.position)
    	End Method
    	
    	'|--------------------------------------------------------------------------------
    	'| DRAW (add inside OnRender)
    	'|--------------------------------------------------------------------------------
    	Method Draw:Void()
    		If DEBUG
    					SetColor 255, 255, 0
    					
    					' collision shape
    					SetAlpha 0.15
    					SetColor 255,255,255
    					Self.collision.DebugDraw_Corners()
    					
    						
    					SetAlpha 1
    					' direction
    					SetColor(0,255,0)
    					DrawLine(	Self.position.x+Self.offset.x,
    								Self.position.y+Self.offset.y,
    								Self.position.x+Self.offset.x+Self.direction.x*32,
    								Self.position.y+Self.offset.y+Self.direction.y*32)
    					
    					' center
    					
    					DrawCircle(	Self.position.x + Self.offset.x , 
    								Self.position.y + Self.offset.y ,2)
    					
    					' inner circle
    					SetAlpha 0.5
    					SetColor(255,255,0)
    					DrawCircle(	Self.position.x + Self.offset.x , Self.position.y + Self.offset.y ,Self.radius)
    					SetColor(255,255,255)
    					SetAlpha 1
    					
    					' collision radius
    					SetColor(255,0,0)
    					SetAlpha 0.5
    					DrawCircle(	Self.position.x + Self.offset.x , Self.position.y + Self.offset.y ,Self.collision.radius)
    					SetColor(255,255,255)
    					SetAlpha 1
    					
    					' collision square
    					
    					
    					Self.collision.DebugDraw_Corners()
    					'SetAlpha 0.5
    					'SetColor(255,0,0)
    					'DrawRectOutline(Self.collision.A.x + Self.offset.x , Self.collision.A.y + Self.offset.y ,Self.collision.size.x,Self.collision.size.y)
    					SetColor(255,255,255)
    					SetAlpha 1
    					
    					'CONSOLE.fnt._DrawText("POS  :" + Self.position.ToString(),Self.position.x-Self.size.x/2,Self.position.y+Self.size.y)
    					'CONSOLE.fnt._DrawText("DIR  :" + Self.direction.ToString(),Self.position.x-Self.size.x/2,Self.position.y+Self.size.y+10)
    					'CONSOLE.fnt._DrawText("ANG  :" + FormatNumber(Self.rotation),Self.position.x-Self.size.x/2,Self.position.y+Self.size.y+20)
    					'CONSOLE.fnt._DrawText("[" + Self.name+"]",Self.position.x-Self.size.x/2,Self.position.y+Self.size.y+30)
    				EndIf
    	End Method
    	
    End Class
    
    
    Please help. :)
    AndyGFX.

    6,681583
    Grand MasterGrand Master
    6,681583

      Sep 22, 2011#2

      I hope the attached wordfile with your color settings is better. I removed 4 duplicate words, corrected "Endif" to "EndIf", added definitions for string highlighting and of course modified the function strings. Please note that you can right click on the function list view and left click on Configuration to open the dialog for editing function strings in the wordfile used to highlight the current file. For a grouped function list definition using the configuration dialog is at least at the beginning better than editing the strings directly in the wordfile.

      As you can see on the screenshot I made there are 2 arguments wrong for method New. I changed the color to red of these 2 arguments. The reason is a bug in UltraEdit. It looks like UltraEdit is searching for arguments in string

      w(n:String,x:Float=0, y:Float=0,w:Int=32,h:Int=

      instead of

      n:String,x:Float=0, y:Float=0,w:Int=32,h:Int=32

      I had reported this character index problem already once a few weeks ago as I searched for a function string set for another language. But it looks like I'm the only user who reported that subgroup string searches is not working correct because of searching in wrongly extracted string which gives the bug a low priority on fixing it. So please report this issue by email to IDM. Pack your wordfile (without any color settings), the example file and the screenshot I made into a ZIP archive attached to the email and write what I have written here. I don't know why the same issue does not occur also on (filename:String) of the function.
      FunctionList.png (2.41KiB)
      Function list displayed with the modified wordfile for the example file.
      Monkey.zip (1.49 KiB)   269
      Updated wordfile for Monkey with color settings of Andy

      2
      NewbieNewbie
      2

        Sep 22, 2011#3

        Wow. Thanks a lot.

        One more question: I tried this wordfile under Mac version (trial), and Function list doesn't work. Do i have to, rewrite him, to linux regular expressions?

        Andy.

        6,681583
        Grand MasterGrand Master
        6,681583

          Sep 22, 2011#4

          I don't know if UEM supports grouped function lists at all. I'm not using UEM. Does the standard wordfile c_cplusplus.uew of UEM contain also the function string definitions for grouped functions? If this is not the case, UEM probably does not yet support grouped function strings.

          Update: I have just read in the UE for Mac Beta forum that next version of UEM has the enhancement of support for hierarchical function list.