2
0
Эх сурвалжийг харах

Added support for operator method examples. Fixes #51.

woollybah 6 жил өмнө
parent
commit
568d43ab7a

+ 1 - 0
src/makemd/docnode.bmx

@@ -20,6 +20,7 @@ Type TDocNode
 	Field example$	'eg: LoadImage.bmx (path)
 	Field example$	'eg: LoadImage.bmx (path)
 	
 	
 	Field children:TList=New TList
 	Field children:TList=New TList
+	Field op:String
 	
 	
 	Function ForPath:TDocNode( path$ )
 	Function ForPath:TDocNode( path$ )
 
 

+ 8 - 0
src/makemd/makemd.bmx

@@ -189,6 +189,7 @@ Function docBmxFile( filePath$,docPath$ )
 		Else If bbdoc
 		Else If bbdoc
 		
 		
 			Local kind$,proto$
 			Local kind$,proto$
+			Local op:String
 			
 			
 			If keyword
 			If keyword
 				id=keyword
 				id=keyword
@@ -203,6 +204,12 @@ Function docBmxFile( filePath$,docPath$ )
 					kind=t
 					kind=t
 					proto=line
 					proto=line
 					id=ParseIdent( line,i )
 					id=ParseIdent( line,i )
+
+					If id.ToLower() = "operator" Then
+						op = ParseOperator(line, i)
+						id :+ op
+					End If
+
 					Exit
 					Exit
 				Next
 				Next
 			EndIf
 			EndIf
@@ -251,6 +258,7 @@ Function docBmxFile( filePath$,docPath$ )
 				node.returns=returns
 				node.returns=returns
 				node.about=about
 				node.about=about
 				node.params=params
 				node.params=params
+				node.op = op
 				
 				
 				If kind="Module" node.docDir=docDir		
 				If kind="Module" node.docDir=docDir		
 
 

+ 2 - 2
src/makemd/mdstyle.bmx

@@ -103,7 +103,7 @@ Type TRstStyle Extends TDocStyle
 				Local id:String = t.id.ToLower()
 				Local id:String = t.id.ToLower()
 				Select category
 				Select category
 					Case "-"
 					Case "-"
-						If id = "new" Or id = "delete" Or id = "operator" Then
+						If id = "new" Or id = "delete" Or t.op Then
 							Continue
 							Continue
 						End If
 						End If
 					Case "Constructor"
 					Case "Constructor"
@@ -115,7 +115,7 @@ Type TRstStyle Extends TDocStyle
 							Continue
 							Continue
 						End If
 						End If
 					Case "Operator"
 					Case "Operator"
-						If id <> "operator" Then
+						If Not t.op Then
 							Continue
 							Continue
 						End If
 						End If
 				End Select
 				End Select

+ 20 - 0
src/makemd/parse.bmx

@@ -1,6 +1,13 @@
 
 
 Strict
 Strict
 
 
+Global OPERATORS:String[] = ["*", "/", "+", "-", "&", "|", "~~", "^", ":*", ":/", ..
+		":+", ":-", ":&", ":|", ":~~", ":^", "<", "<=", ">", ">=", ..
+		"=", "<>", "mod", "shl", "shr", ":mod", ":shl", ":shr", "[]", "[]="]
+Global OPERATOR_MAP:String[] = ["_mul", "_div", "_add", "_sub", "_and", "_or", "_xor", "_pow", "_muleq", ..
+		"_diveq", "_addeq", "_subeq", "_andeq", "_oreq", "_xoreq", "_poweq", "_lt", "_le", "_gt", ..
+		"_ge", "_eq", "_ne", "_mod", "_shl", "_shr", "_modeq", "_shleq", "_shreq", "_iget", "_iset"]
+
 Function IsAlphaChar( char )
 Function IsAlphaChar( char )
 	Return (char>=Asc("A") And char<=Asc("Z")) Or (char>=Asc("a") And char<=Asc("z")) Or (char=Asc("_"))
 	Return (char>=Asc("A") And char<=Asc("Z")) Or (char>=Asc("a") And char<=Asc("z")) Or (char=Asc("_"))
 End Function
 End Function
@@ -55,6 +62,19 @@ Function ParseIdent$( t$,i Var )
 	Return t[i0..i]
 	Return t[i0..i]
 End Function
 End Function
 
 
+Function ParseOperator:String(t:String, i:Int Var)
+	ParseWS t, i
+	Local i0=i
+	For Local n:Int = 0 Until OPERATORS.length
+		Local op:String = OPERATORS[n]
+		Local o:String = t[i..i + op.length]
+		If op = o Then
+			i :+ op.length
+			Return OPERATOR_MAP[n]
+		End If
+	Next
+End Function
+
 Function ParseString$( t$,i Var )
 Function ParseString$( t$,i Var )
 	ParseWS t,i
 	ParseWS t,i
 	If i=t.length Or t[i]<>Asc("~q") Return
 	If i=t.length Or t[i]<>Asc("~q") Return