Переглянути джерело

Added support for operator method examples. Fixes #51.

woollybah 6 роки тому
батько
коміт
568d43ab7a
4 змінених файлів з 31 додано та 2 видалено
  1. 1 0
      src/makemd/docnode.bmx
  2. 8 0
      src/makemd/makemd.bmx
  3. 2 2
      src/makemd/mdstyle.bmx
  4. 20 0
      src/makemd/parse.bmx

+ 1 - 0
src/makemd/docnode.bmx

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

+ 8 - 0
src/makemd/makemd.bmx

@@ -189,6 +189,7 @@ Function docBmxFile( filePath$,docPath$ )
 		Else If bbdoc
 		
 			Local kind$,proto$
+			Local op:String
 			
 			If keyword
 				id=keyword
@@ -203,6 +204,12 @@ Function docBmxFile( filePath$,docPath$ )
 					kind=t
 					proto=line
 					id=ParseIdent( line,i )
+
+					If id.ToLower() = "operator" Then
+						op = ParseOperator(line, i)
+						id :+ op
+					End If
+
 					Exit
 				Next
 			EndIf
@@ -251,6 +258,7 @@ Function docBmxFile( filePath$,docPath$ )
 				node.returns=returns
 				node.about=about
 				node.params=params
+				node.op = op
 				
 				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()
 				Select category
 					Case "-"
-						If id = "new" Or id = "delete" Or id = "operator" Then
+						If id = "new" Or id = "delete" Or t.op Then
 							Continue
 						End If
 					Case "Constructor"
@@ -115,7 +115,7 @@ Type TRstStyle Extends TDocStyle
 							Continue
 						End If
 					Case "Operator"
-						If id <> "operator" Then
+						If Not t.op Then
 							Continue
 						End If
 				End Select

+ 20 - 0
src/makemd/parse.bmx

@@ -1,6 +1,13 @@
 
 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 )
 	Return (char>=Asc("A") And char<=Asc("Z")) Or (char>=Asc("a") And char<=Asc("z")) Or (char=Asc("_"))
 End Function
@@ -55,6 +62,19 @@ Function ParseIdent$( t$,i Var )
 	Return t[i0..i]
 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 )
 	ParseWS t,i
 	If i=t.length Or t[i]<>Asc("~q") Return