From abcc71bd65bca1c89a991915a10f7552da7fba4d Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 09:56:23 -0700 Subject: [PATCH 1/6] Add Xojo lexer. Started with a fresh branch. Simplified the lexer and removed unneeded parsing. --- lib/rouge/demos/xojo | 13 ++ lib/rouge/lexers/xojo.rb | 66 +++++++ spec/visual/samples/xojo | 372 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 451 insertions(+) create mode 100644 lib/rouge/demos/xojo create mode 100644 lib/rouge/lexers/xojo.rb create mode 100644 spec/visual/samples/xojo diff --git a/lib/rouge/demos/xojo b/lib/rouge/demos/xojo new file mode 100644 index 0000000000..e019b2726c --- /dev/null +++ b/lib/rouge/demos/xojo @@ -0,0 +1,13 @@ +Dim f As FolderItem +f = GetOpenFolderItem(FileTypes1.jpeg) // defined in the File Type Set editor +If not f.Exists Then + Beep + MsgBox("The file " + f.NativePath + "doesn't ""exist.""") +Else // document exists + ImageWell1.image=Picture.Open(f) +End If +if f isa folderitem then + msgbox(f.name) +end if +Exception err As NilObjectException + MsgBox("Invalid pathname!") diff --git a/lib/rouge/lexers/xojo.rb b/lib/rouge/lexers/xojo.rb new file mode 100644 index 0000000000..2a7c6bb677 --- /dev/null +++ b/lib/rouge/lexers/xojo.rb @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +module Rouge + module Lexers + class Xojo < RegexLexer + title "Xojo" + desc "Xojo" + tag 'xojo' + aliases 'realbasic' + filenames '*.xojo_code', '*.xojo_window', '*.xojo_toolbar', '*.xojo_menu' + + keywords = %w( + addhandler aggregates array asc assigns attributes begin break + byref byval call case catch class const continue char ctype declare + delegate dim do downto each else elseif end enum event exception + exit extends false finally for function global goto if + implements inherits interface lib loop mod module + new next nil object of optional paramarray + private property protected public raise raiseevent rect redim + removehandler return select shared soft static step sub super + then to true try until using uend uhile + ) + + keywords_type = %w( + boolean cfstringref cgfloat cstring curency date double int8 int16 + int32 int64 integer ostype pstring ptr short single + single string structure variant uinteger uint8 uint16 uint32 uint64 + ushort windowptr wstring + ) + + operator_words = %w( + addressof and as in is isa mod not or xor + ) + + state :whitespace do + rule /\s+/, Text + rule /rem\b.*?$/i, Comment::Single + rule /\/\/.*$/, Comment::Single + rule /\#tag Note.*\#tag EndNote/m, Comment::Doc + rule /".*"/, Literal::String + end + + + state :root do + mixin :whitespace + rule /\s*[#].*$/x, Comment::Preproc + rule /[(){}!#,:]/, Punctuation + rule /\b(?:#{keywords.join('|')})\b/i, Keyword + rule /\b(?:#{keywords_type.join('|')})\b/i, Keyword::Declaration + rule /\b(?:#{operator_words.join('|')})\b/i, Operator + + rule( + %r(<=|>=|<>|[=><\+\-\*\/\\]), + Operator + ) + + rule /[+-]?(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Literal::Number::Float + rule /[+-]?\d+/, Literal::Number::Integer + rule /&[CH][0-9a-f]+/i, Literal::Number::Integer + rule /&O[0-7]+/i, Literal::Number::Oct + rule /\b[\w\.]+\b/i, Text + end + end + end +end diff --git a/spec/visual/samples/xojo b/spec/visual/samples/xojo new file mode 100644 index 0000000000..2deaf57233 --- /dev/null +++ b/spec/visual/samples/xojo @@ -0,0 +1,372 @@ +#tag IOSView +Begin iosView DrawView + BackButtonTitle = "Draw" + Compatibility = "" + Left = 0 + NavigationBarVisible= True + TabIcon = "" + TabTitle = "" + Title = "Xojo Draw" + Top = 0 + Begin iOSCanvas DrawingCanvas + AccessibilityHint= "" + AccessibilityLabel= "" + AutoLayout = DrawingCanvas, 4, BottomLayoutGuide, 3, False, +1.00, 2, 1, 0, + AutoLayout = DrawingCanvas, 1, , 1, False, +1.00, 1, 1, 0, + AutoLayout = DrawingCanvas, 2, , 2, False, +1.00, 2, 1, 0, + AutoLayout = DrawingCanvas, 3, TopLayoutGuide, 4, False, +1.00, 1, 1, 0, + Height = 503.0 + Left = 0 + LockedInPosition= False + Scope = 0 + Top = 65 + Visible = True + Width = 320.0 + End + Begin iOSToolButton ClearButton + Caption = "Clear" + Enabled = True + Height = 22 + Image = "0" + Image = "0" + Left = 8 + LockedInPosition= False + Scope = 2 + Top = 534 + Type = "1001" + Width = 41.0 + End + Begin iOSToolButton ShareButton + Caption = "Untitled" + Enabled = True + Height = 22 + Image = "0" + Image = "0" + Left = 290 + LockedInPosition= False + Scope = 2 + Top = 32 + Type = "9" + Width = 22.0 + End + Begin iOSToolButton SaveButton + Caption = "Save" + Enabled = True + Height = 22 + Image = "0" + Image = "0" + Left = 8 + LockedInPosition= False + Scope = 2 + Top = 32 + Type = "3" + Width = 40.0 + End + Begin iOSButton RemoveMeButton + AccessibilityHint= "" + AccessibilityLabel= "" + AutoLayout = RemoveMeButton, 7, , 0, False, +1.00, 1, 1, 39, + AutoLayout = RemoveMeButton, 2, DrawingCanvas, 2, False, +1.00, 1, 1, 0, + AutoLayout = RemoveMeButton, 3, , 3, False, +1.00, 1, 1, 73, + AutoLayout = RemoveMeButton, 4, , 3, False, +1.00, 1, 1, 96, + Caption = "S" + Enabled = True + Height = 23.0 + Left = 281 + LockedInPosition= False + Scope = 2 + TextColor = &c007AFF00 + TextFont = "" + TextSize = 0 + Top = 73 + Visible = False + Width = 39.0 + End + Begin iOSToolButton FlexibleSpace + Caption = "Set Color" + Enabled = True + Height = 22 + Image = "0" + Image = "0" + Left = 58 + LockedInPosition= False + Scope = 2 + Top = 534 + Type = "5" + Width = 223.0 + End + Begin iOSToolButton PenSizeButton + Caption = "Pen Size" + Enabled = True + Height = 22 + Image = "705015807" + Image = "705015807" + Left = 249 + LockedInPosition= False + Scope = 2 + Top = 534 + Type = "1001" + Width = 22.0 + End +End +#tag EndIOSView + +#tag WindowCode + #tag Event + Sub Activate() + DrawingCanvas.Invalidate + End Sub + #tag EndEvent + + #tag Event + Sub Open() + // Load image if saved + Dim loadFile As FolderItem = SpecialFolder.Documents.Child("XojoDoodle.png") + If loadFile.Exists Then + Dim pic As iOSImage = iOSImage.FromFile(loadFile) + DrawingImage = New iOSBitmap(pic.Width, pic.Height, 1.0, True) + DrawingImage.Graphics.DrawImage(pic, 0, 0) + End If + + // Add a button for the about view + Dim aboutButton As iOSToolButton = iOSToolButton.NewPlain(QuestionMarkImage) + aboutButton.Tag = "AboutButton" + RightNavigationToolbar.Add(aboutButton) + End Sub + #tag EndEvent + + #tag Event + Sub Resized() + // Need to adjust drawing area of size of canvas is changed + // due to device orientation change. + + LayoutChanged = True + + DrawingCanvas.Invalidate + End Sub + #tag EndEvent + + #tag Event + Sub ToolbarPressed(button As iOSToolButton) + // Process the button taps + select case button + Case ClearButton + // Clear button was pressed, so erase image + DrawingImage = Nil + DrawingCanvas.Invalidate + Case ShareButton + Dim panel As New iOSSharingPanel + panel.SharePicture(DrawingImage.Image, Self, RemoveMeButton) + Case SaveButton + SaveToCameraRoll + Case PenSizeButton + Dim v As New PenSizeView + PushTo(v) + Else + Select Case button.Tag + Case "AboutButton" + Dim v As New AboutView + PushTo(v) + End Select + End Select + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Function MainScreenScale() As Double + Declare function NSClassFromString Lib "Foundation" (aClassName As CFStringRef) As Ptr + Declare Function scale Lib "Foundation" Selector "scale" (classRef As Ptr) As CGFloat + Declare Function mainScreen Lib "Foundation" Selector "mainScreen" (classRef As Ptr) As Ptr + + Return scale(mainScreen(NSClassFromString("UIScreen"))) + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub SaveImage() + // Save the image so it can be reloaded when + // the user comes back to the app. + Dim saveFile As FolderItem = SpecialFolder.Documents.Child("XojoDraw.png") + + if DrawingImage <> nil then + DrawingImage.Image.WriteToFile(saveFile, "public.png") + end if + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub SaveToCameraRoll() + // Directly call UIKit method to save the picture directly + // to the camera roll. + Declare Sub UIImageWriteToSavedPhotosAlbum Lib "UIKit" _ + (img As Ptr, target As Ptr, sel As Ptr, info As Ptr) + UIImageWriteToSavedPhotosAlbum(DrawingImage.Image.Handle, Nil, Nil, Nil) + + End Sub + #tag EndMethod + + + #tag Note, Name = RemoveMeButton + The RemoveMe button is only used so that the sharing panel + on iPad has a parent control it can use to display itself + near the actual toolbar button that displays it. + + When this feedback case is resolve, the button can be removed: + + + #tag EndNote + + + #tag Property, Flags = &h21 + Private ColorButton As iOSToolButton + #tag EndProperty + + #tag Property, Flags = &h21 + Private DrawingImage As iOSBitmap + #tag EndProperty + + #tag Property, Flags = &h21 + Private LastDragPosition As Point + #tag EndProperty + + #tag Property, Flags = &h21 + Private LayoutChanged As Boolean + #tag EndProperty + + +#tag EndWindowCode + +#tag Events DrawingCanvas + #tag Event + Sub Paint(g As iOSGraphics) + Dim scale As Double = MainScreenScale + If DrawingImage Is Nil Then + // Create an image if one does not already exist + DrawingImage = New iOSBitmap(g.Width, g.Height, scale, True) + DrawingImage.Graphics.Scale(scale, scale) + DrawingImage.Graphics.FillColor = &cffffff // White + DrawingImage.Graphics.FillRect(0, 0, DrawingImage.Graphics.Width, DrawingImage.Graphics.Height) + ElseIf LayoutChanged Then + // Create image in new screen size and copy old image to it + Dim oldImage As iOSBitmap = DrawingImage + DrawingImage = New iOSBitmap(g.Width, g.Height, scale, True) + DrawingImage.Graphics.Scale(scale, scale) + DrawingImage.Graphics.FillColor = &cffffff // White + DrawingImage.Graphics.FillRect(0, 0, DrawingImage.Graphics.Width, DrawingImage.Graphics.Height) + // Copy the old image to the new image any information that does not fit is lost + DrawingImage.Graphics.DrawImage(oldImage.Image, 0, 0, oldImage.Width, oldImage.Height) + LayoutChanged = False + End If + + // Draw the image to the Canvas + g.DrawImage(DrawingImage, 0, 0) + + // Draw the "Color" button over the drawing + // so that it is not part of the actual drawing + // and does not get saved. + g.FillColor = App.Colors(App.CurrentColorIndex) + g.FillRect(0, g.Height - App.LineSize, g.Width, App.LineSize) + + End Sub + #tag EndEvent + #tag Event + Sub PointerUp(pos As Xojo.Core.Point, eventInfo As iOSEventInfo) + // Clear the drag position so that when the user + // starts drawing again, it does not connect a line + // from where they last drew. + LastDragPosition = Nil + + Me.Invalidate + + // Save the image whenever they stop drawing + SaveImage + End Sub + #tag EndEvent + #tag Event + Sub PointerDrag(pos As Xojo.Core.Point, eventInfo As iOSEventInfo) + // Draw a line following the touches as they drag on the Canvas + Dim scalePos As New Xojo.Core.Point(pos.X * MainScreenScale, pos.Y * MainScreenScale) + + Dim g As iOSGraphics = DrawingImage.Graphics + + If LastDragPosition <> Nil Then + // Draw a line from the last position to the current position + g.FillColor = App.Colors(App.CurrentColorIndex) + g.LineColor = App.Colors(App.CurrentColorIndex) + g.LineWidth = App.LineSize + g.FillOval(LastDragPosition.X, LastDragPosition.Y, App.LineSize, App.LineSize) + g.DrawLine(LastDragPosition.X + App.LineSize / 2, _ + LastDragPosition.Y + App.LineSize / 2, _ + pos.X + App.LineSize / 2, _ + pos.Y + App.LineSize / 2) + End If + + LastDragPosition = pos + + Me.Invalidate + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="BackButtonTitle" + Group="Behavior" + Type="Text" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="NavigationBarVisible" + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="TabIcon" + Group="Behavior" + Type="iOSImage" + #tag EndViewProperty + #tag ViewProperty + Name="TabTitle" + Group="Behavior" + Type="Text" + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Group="Behavior" + Type="Text" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty +#tag EndViewBehavior From 9c57d19901767120687e3779266a23b6f70fb031 Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 10:35:05 -0700 Subject: [PATCH 2/6] Fixed whitespace in xojo.rb --- lib/rouge/lexers/xojo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge/lexers/xojo.rb b/lib/rouge/lexers/xojo.rb index 2a7c6bb677..75c4a26404 100644 --- a/lib/rouge/lexers/xojo.rb +++ b/lib/rouge/lexers/xojo.rb @@ -42,7 +42,7 @@ class Xojo < RegexLexer end - state :root do + state :root do mixin :whitespace rule /\s*[#].*$/x, Comment::Preproc rule /[(){}!#,:]/, Punctuation From dc50b56323dd4a10f5e1dc9a1888cd65ac4bcfdb Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 10:57:56 -0700 Subject: [PATCH 3/6] add xojo_spec.rb --- spec/lexers/xojo_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spec/lexers/xojo_spec.rb diff --git a/spec/lexers/xojo_spec.rb b/spec/lexers/xojo_spec.rb new file mode 100644 index 0000000000..976df5b0a4 --- /dev/null +++ b/spec/lexers/xojo_spec.rb @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +describe Rouge::Lexers::Xojo do + let(:subject) { Rouge::Lexers::Xojo.new } + + describe 'guessing' do + include Support::Guessing + + it 'guesses by filename' do + assert_guess :filename => 'foo.xojo_code' + assert_guess :filename => 'foo.xojo_window' + assert_guess :filename => 'foo.xojo_toolbar' + assert_guess :filename => 'foo.xojo_menu' + end + + end +end From ce1e7fe0781a49afc1fb413a5c7ac3ce94654d56 Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 18:13:46 -0700 Subject: [PATCH 4/6] Simplified sample to eliminate redundant code. Added an intentional error to test for 1..0 being read as a valid float --- spec/visual/samples/xojo | 128 +-------------------------------------- 1 file changed, 3 insertions(+), 125 deletions(-) diff --git a/spec/visual/samples/xojo b/spec/visual/samples/xojo index 2deaf57233..a5212de437 100644 --- a/spec/visual/samples/xojo +++ b/spec/visual/samples/xojo @@ -23,91 +23,6 @@ Begin iosView DrawView Visible = True Width = 320.0 End - Begin iOSToolButton ClearButton - Caption = "Clear" - Enabled = True - Height = 22 - Image = "0" - Image = "0" - Left = 8 - LockedInPosition= False - Scope = 2 - Top = 534 - Type = "1001" - Width = 41.0 - End - Begin iOSToolButton ShareButton - Caption = "Untitled" - Enabled = True - Height = 22 - Image = "0" - Image = "0" - Left = 290 - LockedInPosition= False - Scope = 2 - Top = 32 - Type = "9" - Width = 22.0 - End - Begin iOSToolButton SaveButton - Caption = "Save" - Enabled = True - Height = 22 - Image = "0" - Image = "0" - Left = 8 - LockedInPosition= False - Scope = 2 - Top = 32 - Type = "3" - Width = 40.0 - End - Begin iOSButton RemoveMeButton - AccessibilityHint= "" - AccessibilityLabel= "" - AutoLayout = RemoveMeButton, 7, , 0, False, +1.00, 1, 1, 39, - AutoLayout = RemoveMeButton, 2, DrawingCanvas, 2, False, +1.00, 1, 1, 0, - AutoLayout = RemoveMeButton, 3, , 3, False, +1.00, 1, 1, 73, - AutoLayout = RemoveMeButton, 4, , 3, False, +1.00, 1, 1, 96, - Caption = "S" - Enabled = True - Height = 23.0 - Left = 281 - LockedInPosition= False - Scope = 2 - TextColor = &c007AFF00 - TextFont = "" - TextSize = 0 - Top = 73 - Visible = False - Width = 39.0 - End - Begin iOSToolButton FlexibleSpace - Caption = "Set Color" - Enabled = True - Height = 22 - Image = "0" - Image = "0" - Left = 58 - LockedInPosition= False - Scope = 2 - Top = 534 - Type = "5" - Width = 223.0 - End - Begin iOSToolButton PenSizeButton - Caption = "Pen Size" - Enabled = True - Height = 22 - Image = "705015807" - Image = "705015807" - Left = 249 - LockedInPosition= False - Scope = 2 - Top = 534 - Type = "1001" - Width = 22.0 - End End #tag EndIOSView @@ -115,6 +30,9 @@ End #tag Event Sub Activate() DrawingCanvas.Invalidate + dim x as double=1..0 //this should error on the double dot + rem This is an old style comment (throw back to Basic) + dim escaped_quotes as string="this is an ""escaped"" string" //would compile as 'this is an "escaped" string' End Sub #tag EndEvent @@ -329,44 +247,4 @@ End InitialValue="0" Type="Integer" #tag EndViewProperty - #tag ViewProperty - Name="Name" - Visible=true - Group="ID" - Type="String" - #tag EndViewProperty - #tag ViewProperty - Name="NavigationBarVisible" - Group="Behavior" - Type="Boolean" - #tag EndViewProperty - #tag ViewProperty - Name="Super" - Visible=true - Group="ID" - Type="String" - #tag EndViewProperty - #tag ViewProperty - Name="TabIcon" - Group="Behavior" - Type="iOSImage" - #tag EndViewProperty - #tag ViewProperty - Name="TabTitle" - Group="Behavior" - Type="Text" - #tag EndViewProperty - #tag ViewProperty - Name="Title" - Group="Behavior" - Type="Text" - EditorType="MultiLineEditor" - #tag EndViewProperty - #tag ViewProperty - Name="Top" - Visible=true - Group="Position" - InitialValue="0" - Type="Integer" - #tag EndViewProperty #tag EndViewBehavior From 96f71d21fbaab20aeb584e52e8e0022c7c4b4099 Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 18:20:56 -0700 Subject: [PATCH 5/6] Fixed some spacing issues. Removed state sections. This lexer is simple enough that states are really not needed at this point. Added word boundary to the Float regex to avoid 1..0 being read as a valid float. Adjusted double-quote regex to allow for (and enforce) escaped quotes (two double quotes with no space between) I may revisit this in the future. &HFFEEDD style literals now marked as Literal.Number.Hex rather than Integer --- lib/rouge/lexers/xojo.rb | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/rouge/lexers/xojo.rb b/lib/rouge/lexers/xojo.rb index 75c4a26404..c94b82a622 100644 --- a/lib/rouge/lexers/xojo.rb +++ b/lib/rouge/lexers/xojo.rb @@ -10,7 +10,7 @@ class Xojo < RegexLexer aliases 'realbasic' filenames '*.xojo_code', '*.xojo_window', '*.xojo_toolbar', '*.xojo_menu' - keywords = %w( + keywords = %w( addhandler aggregates array asc assigns attributes begin break byref byval call case catch class const continue char ctype declare delegate dim do downto each else elseif end enum event exception @@ -22,44 +22,39 @@ class Xojo < RegexLexer then to true try until using uend uhile ) - keywords_type = %w( + keywords_type = %w( boolean cfstringref cgfloat cstring curency date double int8 int16 int32 int64 integer ostype pstring ptr short single single string structure variant uinteger uint8 uint16 uint32 uint64 ushort windowptr wstring ) - operator_words = %w( + operator_words = %w( addressof and as in is isa mod not or xor ) - state :whitespace do - rule /\s+/, Text + state :root do + rule /\s+/, Text::Whitespace + rule /rem\b.*?$/i, Comment::Single rule /\/\/.*$/, Comment::Single - rule /\#tag Note.*\#tag EndNote/m, Comment::Doc - rule /".*"/, Literal::String - end - - - state :root do - mixin :whitespace + rule /\#tag Note.*\#tag EndNote/m, Comment::Preproc rule /\s*[#].*$/x, Comment::Preproc + + rule /".*?"/, Literal::String::Double rule /[(){}!#,:]/, Punctuation + rule /\b(?:#{keywords.join('|')})\b/i, Keyword rule /\b(?:#{keywords_type.join('|')})\b/i, Keyword::Declaration - rule /\b(?:#{operator_words.join('|')})\b/i, Operator - - rule( - %r(<=|>=|<>|[=><\+\-\*\/\\]), - Operator - ) - rule /[+-]?(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Literal::Number::Float + rule /\b(?:#{operator_words.join('|')})\b/i, Operator + rule /[+-]?(\d+\.\d*|\d*\.\d+)\b/i, Literal::Number::Float rule /[+-]?\d+/, Literal::Number::Integer - rule /&[CH][0-9a-f]+/i, Literal::Number::Integer + rule /&[CH][0-9a-f]+/i, Literal::Number::Hex rule /&O[0-7]+/i, Literal::Number::Oct + rule /\b[\w\.]+\b/i, Text + rule(%r(<=|>=|<>|[=><\+\-\*\/\\]), Operator) end end end From d11561fdbe659b611acab3a7a07e569c49c32885 Mon Sep 17 00:00:00 2001 From: Jim M Date: Tue, 28 May 2019 18:38:08 -0700 Subject: [PATCH 6/6] Fixed Float regex to allow .1 and 1. as valid Floats Added example to sample --- lib/rouge/lexers/xojo.rb | 2 +- spec/visual/samples/xojo | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rouge/lexers/xojo.rb b/lib/rouge/lexers/xojo.rb index c94b82a622..33459aa6d8 100644 --- a/lib/rouge/lexers/xojo.rb +++ b/lib/rouge/lexers/xojo.rb @@ -48,7 +48,7 @@ class Xojo < RegexLexer rule /\b(?:#{keywords_type.join('|')})\b/i, Keyword::Declaration rule /\b(?:#{operator_words.join('|')})\b/i, Operator - rule /[+-]?(\d+\.\d*|\d*\.\d+)\b/i, Literal::Number::Float + rule /[+-]?(\d+\.\d*|\d*\.\d+)/i, Literal::Number::Float rule /[+-]?\d+/, Literal::Number::Integer rule /&[CH][0-9a-f]+/i, Literal::Number::Hex rule /&O[0-7]+/i, Literal::Number::Oct diff --git a/spec/visual/samples/xojo b/spec/visual/samples/xojo index a5212de437..d72a973e18 100644 --- a/spec/visual/samples/xojo +++ b/spec/visual/samples/xojo @@ -15,7 +15,7 @@ Begin iosView DrawView AutoLayout = DrawingCanvas, 1, , 1, False, +1.00, 1, 1, 0, AutoLayout = DrawingCanvas, 2, , 2, False, +1.00, 2, 1, 0, AutoLayout = DrawingCanvas, 3, TopLayoutGuide, 4, False, +1.00, 1, 1, 0, - Height = 503.0 + Height = 503. Left = 0 LockedInPosition= False Scope = 0 @@ -30,7 +30,8 @@ End #tag Event Sub Activate() DrawingCanvas.Invalidate - dim x as double=1..0 //this should error on the double dot + dim x as double=1. //this is allowed + dim y as double=.1 //also allowed rem This is an old style comment (throw back to Basic) dim escaped_quotes as string="this is an ""escaped"" string" //would compile as 'this is an "escaped" string' End Sub