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

Moved src/mx2new to src/mx2cc

Mark Sibly 9 роки тому
батько
коміт
f389b73141

+ 0 - 0
src/mx2new/alias.monkey2 → src/mx2cc/alias.monkey2


+ 0 - 0
src/mx2new/balance.monkey2 → src/mx2cc/balance.monkey2


+ 0 - 0
src/mx2new/builder.monkey2 → src/mx2cc/builder.monkey2


+ 0 - 0
src/mx2new/class.monkey2 → src/mx2cc/class.monkey2


+ 0 - 0
src/mx2new/decl.monkey2 → src/mx2cc/decl.monkey2


+ 95 - 10
src/mx2new/docs/docsmaker.monkey2 → src/mx2cc/docs/docsmaker.monkey2

@@ -44,7 +44,8 @@ Class DocsMaker
 			Local md:=stringio.LoadString( mdocs )
 			_linkScope=Null
 			_md.Emit( md )
-			page=_module.name+"-default"
+			page="module"
+'			page=_module.name+"-Default"
 			SavePage( _md.Flush(),page )
 		Endif
 
@@ -63,6 +64,85 @@ Class DocsMaker
 		Return tree
 	End
 	
+	'Kludgy as!
+	'
+	'Converts the 'TOC' tree generated by stackedit into a json nav tree...
+	'
+	Method MakeLangNav:String()
+	
+		#rem
+		Local md:=stringio.LoadString( "docs/The Monkey2 Language.md" )
+		_md.Emit( md )
+		Local html:=_md.Flush()
+		
+		Local src:=stringio.LoadString( "docs/monkey2-language-template.html" )
+		src=src.Replace( "${CONTENT}",html )
+		
+		stringio.SaveString( src,"docs/The Monkey2 Language.html" )
+		#End
+		
+		Local src:=stringio.LoadString( "docs/The Monkey2 Language.html" )
+		
+		src=src.Replace( "~r~n","~n" )
+		
+		Local tag1:="<p><div class=~qtoc~q>"
+		Local tag2:="</div>"
+		
+		Local i:=src.Find( tag1 )
+		If i=-1
+			Print "Can't find lang TOC div"
+			Return ""
+		Endif
+
+		Local i2:=src.Find( tag2,i+tag1.Length )
+		If i2=-1
+			Print "Can't find lang TOC /div"
+			Return ""
+		Endif
+		
+		src=src.Slice( i+tag1.Length,i2 )
+		
+		Local nest:=0
+		
+		For Local line:=Eachin src.Split( "~n" )
+		
+			If line="</ul>"
+			
+				If nest
+					_nav.Emit( "]}" )
+					nest-=1
+				Endif
+			
+			Else If line="</li>"
+			
+			Else If line.StartsWith( "<li>" )
+			
+				Local i:=line.Find( "<a href=~q#" )
+				If i=-1 Continue
+				Local i2:=line.Find( "~q>",i+10 )
+				If i2=-1 Continue
+				Local i3:=line.Find( "</a>",i2+2 )
+				If i3=-1 Continue
+				
+				Local href:=line.Slice( i+10,i2 )
+				Local text:=line.Slice( i2+2,i3 )
+				
+				If line.EndsWith( "<ul>" )
+					nest+=1
+					_nav.Emit( "{text:~q"+text+"~q,data:{topic:~q"+href+"~q},children:[" )
+				Else If line.EndsWith( "</li>" )
+					_nav.Emit( "{text:~q"+text+"~q,data:{topic:~q"+href+"~q}}" )
+				Endif
+				
+			Endif
+			
+		Next
+		
+		Local tree:=_nav.Flush()
+		
+		Return tree
+	End
+	
 	Private
 	
 	Field _nav:JsonBuffer
@@ -127,14 +207,14 @@ Class DocsMaker
 	
 		Local slug:=DeclSlug( decl,scope )
 		
-		Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qdocsLinkClicked('"+slug+"')~q>"+text+"</a>"
+		Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qopenDocsPage('"+slug+"')~q>"+text+"</a>"
 	End
 	
 	Method MakeLink:String( text:String,nmspace:NamespaceScope )
 	
 		Local slug:=NamespaceSlug( nmspace )
 		
-		Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qdocsLinkClicked('"+slug+"')~q>"+text+"</a>"
+		Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qopenDocsPage('"+slug+"')~q>"+text+"</a>"
 	End
 
 	Method ResolveLink:String( path:String,scope:Scope )
@@ -148,8 +228,10 @@ Class DocsMaker
 			Local i1:=path.Find( ".",i0 )
 			If i1=-1
 			
-				Local id:=path.Slice( i0 )
+				If Not scope Return ""
 
+				Local id:=path.Slice( i0 )
+				
 				Local node:=scope.FindNode( id )
 				If Not node
 					Return path
@@ -166,6 +248,9 @@ Class DocsMaker
 				Local etype:=TCast<EnumType>( node )
 				If etype Return MakeLink( tpath,etype.edecl,etype.scope.outer )
 				
+				Local ntype:=TCast<NamespaceType>( node )
+				If ntype Return MakeLink( tpath,ntype.scope )
+				
 				Local ctype:=TCast<ClassType>( node )
 				If ctype Return MakeLink( tpath,ctype.cdecl,ctype.scope.outer )
 				
@@ -202,18 +287,18 @@ Class DocsMaker
 				Continue
 			Endif
 			
-			Local etype:=TCast<EnumType>( type )
-			If etype
-				'stop at enum!
-				Return MakeLink( tpath+"."+path.Slice( i0 ),etype.edecl,etype.scope.outer )
-			Endif
-			
 			Local ctype:=TCast<ClassType>( type )
 			If ctype
 				scope=ctype.scope
 				Continue
 			Endif
 			
+			Local etype:=TCast<EnumType>( type )
+			If etype
+				'stop at Enum!
+				Return MakeLink( tpath+"."+path.Slice( i0 ),etype.edecl,etype.scope.outer )
+			Endif
+			
 			Return ""
 			
 		Forever

+ 0 - 0
src/mx2new/docs/jsonbuffer.monkey2 → src/mx2cc/docs/jsonbuffer.monkey2


+ 34 - 0
src/mx2new/docs/markdownbuffer.monkey2 → src/mx2cc/docs/markdownbuffer.monkey2

@@ -1,6 +1,27 @@
 
 Namespace mx2.docs
 
+Function Slugify:String( str:String )
+	Local st:=0
+	While st<str.Length And Not IsIdent( str[st] )
+		st+=1
+	Wend
+	Local en:=str.Length
+	While en>st And Not IsIdent( str[en-1] )
+		en-=1
+	Wend
+	Local out:=""
+	For Local i:=st Until en
+		Local chr:=str[i]
+		If IsIdent( chr )
+			out+=String.FromChar( chr ).ToLower()
+			Continue
+		Endif
+		out+="-"
+	Next
+	Return out
+End
+
 Class MarkdownBuffer
 
 	Alias LinkResolver:String( link:String )
@@ -26,6 +47,16 @@ Class MarkdownBuffer
 		
 			Local line:=lines[i].Trim()
 			
+			#rem
+			If line.StartsWith( "#" )
+				Local j:=FindSpc( line )
+				Local id:=line.Slice( j ).Trim()
+				Local slug:=Slugify( id )
+				_buf.Push( "<h"+j+" id='"+slug+"'>"+id+"</h"+j+">" )
+				continue
+			End
+			#End
+			
 			If line.StartsWith( "@" )
 
 				Local j:=FindSpc( line )
@@ -135,6 +166,9 @@ Class MarkdownBuffer
 	Field _return:String
 	Field _label:String
 	
+	Field _toc:=New JsonBuffer
+	Field _tocNest:Int
+	
 	Method FindSpc:Int( str:String )
 		For Local i:=0 Until str.Length
 			If str[i]<=32 Return i

+ 0 - 0
src/mx2new/dox_matrix.txt → src/mx2cc/dox_matrix.txt


+ 0 - 0
src/mx2new/enum.monkey2 → src/mx2cc/enum.monkey2


+ 0 - 0
src/mx2new/errors.monkey2 → src/mx2cc/errors.monkey2


+ 0 - 0
src/mx2new/eval.monkey2 → src/mx2cc/eval.monkey2


+ 0 - 0
src/mx2new/expr.monkey2 → src/mx2cc/expr.monkey2


+ 0 - 0
src/mx2new/func.monkey2 → src/mx2cc/func.monkey2


+ 0 - 0
src/mx2new/module.monkey2 → src/mx2cc/module.monkey2


+ 0 - 0
src/mx2new/mung.monkey2 → src/mx2cc/mung.monkey2


+ 1 - 1
src/mx2new/mx2.monkey2 → src/mx2cc/mx2.monkey2

@@ -48,4 +48,4 @@ Using lib.c
 ' 3) edit .sh and .bat files to use new version (common.sh, common.bat)
 ' 4) ./rebuildall
 '
-Const MX2CC_VERSION:="011"
+Const MX2CC_VERSION:="1.0.0"

+ 11 - 7
src/mx2new/mx2cc.monkey2 → src/mx2cc/mx2cc.monkey2

@@ -18,9 +18,9 @@ Using mx2..
 
 Global StartDir:String
 
-Const TestArgs:="mx2cc makemods"
+'Const TestArgs:="mx2cc makemods"
 
-'Const TestArgs:="mx2cc makedocs monkey std mojo"
+Const TestArgs:="mx2cc makedocs monkey std mojo"
 
 'Const TestArgs:="mx2cc makeapp src/mx2new/test.monkey2"
 
@@ -32,7 +32,7 @@ Const TestArgs:="mx2cc makemods"
 
 Function Main()
 
-	Print "MX2CC V0."+MX2CC_VERSION
+	Print "mx2cc version "+MX2CC_VERSION
 
 	StartDir=CurrentDir()
 
@@ -222,10 +222,14 @@ Function MakeDocs( args:String[] )
 	Next
 	
 '	stringio.SaveString( "mx2_api_tree="+mx2_api+";","docs/api-tree.js" )
-	
-	Local index:=stringio.LoadString( "docs/modules_template.html" )
-	index=index.Replace( "${MX2_API}",mx2_api )
-	stringio.SaveString( index,"docs/modules.html" )
+	Local mods:=stringio.LoadString( "docs/modules_template.html" )
+	mods=mods.Replace( "${MX2_API}",mx2_api )
+	stringio.SaveString( mods,"docs/modules.html" )
+	
+	Local lang_nav:=docsMaker.MakeLangNav()
+	Local lang:=stringio.LoadString( "docs/language_template.html" )
+	lang=lang.Replace( "${LANG_NAV}",lang_nav )
+	stringio.SaveString( lang,"docs/language.html" )
 	
 End
 

+ 0 - 0
src/mx2new/namespace.monkey2 → src/mx2cc/namespace.monkey2


+ 0 - 0
src/mx2new/node.monkey2 → src/mx2cc/node.monkey2


+ 0 - 0
src/mx2new/overload.monkey2 → src/mx2cc/overload.monkey2


+ 0 - 0
src/mx2new/parser.monkey2 → src/mx2cc/parser.monkey2


+ 0 - 0
src/mx2new/property.monkey2 → src/mx2cc/property.monkey2


+ 0 - 0
src/mx2new/scope.monkey2 → src/mx2cc/scope.monkey2


+ 0 - 0
src/mx2new/staticexpr.monkey2 → src/mx2cc/staticexpr.monkey2


+ 0 - 0
src/mx2new/stmt.monkey2 → src/mx2cc/stmt.monkey2


+ 0 - 0
src/mx2new/stmtexpr.monkey2 → src/mx2cc/stmtexpr.monkey2


+ 8 - 0
src/mx2cc/test.monkey2

@@ -0,0 +1,8 @@
+
+Namespace test
+
+#rem
+#end
+Function Main()
+End
+

+ 0 - 0
src/mx2new/test2.monkey2 → src/mx2cc/test2.monkey2


+ 0 - 0
src/mx2new/toker.monkey2 → src/mx2cc/toker.monkey2


+ 0 - 0
src/mx2new/translator.monkey2 → src/mx2cc/translator.monkey2


+ 0 - 0
src/mx2new/translator_cpp.monkey2 → src/mx2cc/translator_cpp.monkey2


+ 0 - 0
src/mx2new/type.monkey2 → src/mx2cc/type.monkey2


+ 0 - 0
src/mx2new/typeexpr.monkey2 → src/mx2cc/typeexpr.monkey2


+ 0 - 0
src/mx2new/util.monkey2 → src/mx2cc/util.monkey2


+ 0 - 0
src/mx2new/value.monkey2 → src/mx2cc/value.monkey2


+ 0 - 0
src/mx2new/var.monkey2 → src/mx2cc/var.monkey2


+ 0 - 43
src/mx2new/test.monkey2

@@ -1,43 +0,0 @@
-
-Namespace test
-
-#Import "<std>"
-
-Using std..
-
-Interface I1
-End
-
-Interface I2
-	Method Test()
-End
-
-Class C1 Implements I1
-End
-
-Class C2 Implements I2
-End
-
-Class C3 Extends C1 Implements I2
-	Method Test()
-		Print "C3.Test"
-	End
-End
-
-Enum E
-	X,Y,Z
-End
-
-Function Main()
-
-	Local i1:I1=New C3
-	
-	Local i2:I2=Cast<I2>( i1 )
-	
-	i2.Test()
-	
-	Local e:E=E.X
-	
-	Local t:Byte=e
-
-End