• 大小: 136KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-10-16
  • 语言: Java
  • 标签: CMM  解释器  

资源简介

含词法分析器、语法分析、语义分析、界面等的完整解释器实现。MyEclipse项目

资源截图

代码片段和文件信息

package graphic;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;



import javax.swing.JTextArea;
import javax.swing.border.AbstractBorder;
public class LineNumberBorder extends AbstractBorder {
 public LineNumberBorder(){
 
 }

 /*Insets 对象是容器边界的表示形式。
                          它指定容器必须在其各个边缘留出的空间。
 */
 //此方法在实例化时自动调用
 //此方法关系到边框是否占用组件的空间
 public Insets getBorderInsets(Component c)
 {
return getBorderInsets(cnew Insets(0000)); 
 }
 
 public Insets getBorderInsets(Component c Insets insets)
 {
 if(c instanceof JTextArea){
 int width=lineNumberWidth((JTextArea)c);
 insets.left=width;
 }
 return insets;
       
 }
 
 public boolean isBorderOpaque()
 {
 return false;
 }
 //边框的绘制方法
 //此方法必须实现
 public void paintBorder(Component c Graphics g int x int y int width int height)
     {
 //获得当前剪贴区域的边界矩形。
      java.awt.Rectangle clip=g.getClipBounds();
      FontMetrics fm=g.getFontMetrics();
      int fontHeight=fm.getHeight();
      
      //starting location at the “top“ of the page...
      // y is the starting baseline for the font...
      int ybaseline=y+fm.getAscent();
      
      // now determine if it is the “top“ of the page...or somewhere else
      int startingLineNumber=(clip.y/fontHeight)+1;
      
      if(startingLineNumber!=1){
      ybaseline=y+startingLineNumber*fontHeight-
                 (fontHeight-fm.getAscent());
      }
      
      int yend=ybaseline+height;
      if(yend>(y+height)){
      yend=y+height;
      }
      
      JTextArea jta=(JTextArea)c;
      int lineWidth=lineNumberWidth(jta);
      
      int lnxStart=x+lineWidth;
      
      g.setColor(Color.blue);
      
      
      // loop until out of the “visible“ region...
      int length=(““+Math.max(jta.getRows() jta.getLineCount()+1)).length();
         //绘制行号
      while(ybaseline         {
          String label = padLabel(startingLineNumber length true);
          
          g.drawString(label lnxStart- fm.stringWidth(label)  ybaseline);
          ybaseline+=fontHeight;
          startingLineNumber++;
         }
     }
     
     //寻找适合的数字宽度
     private int lineNumberWidth(JTextArea jta){
      int lineCount=Math.max(jta.getRows() jta.getLineCount());
      return jta.getFontMetrics(jta.getFont()).stringWidth(lineCount+“ “);
     }
     
     private static String padLabel(int lineNumber int length boolean addSpace)
     {
      StringBuffer buffer=new StringBuffer();
      buffer.append(lineNumber);
      for(int count=(length-buffer.length());count>0;count--){
      buffer.insert(0 ‘ ‘);
      }
      if(addSpace){
      buffer.append(‘ ‘);
      }
      return buffer.toString();
     }
     
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        232  2009-11-19 15:29  Interpretor\.classpath

     文件        387  2009-11-19 15:29  Interpretor\.project

     文件       3435  2009-12-11 16:50  Interpretor\bin\graphic\LineNumberBorder.class

     文件       1793  2009-12-17 14:37  Interpretor\bin\graphic\MyRenderer.class

     文件      10692  2009-12-17 14:42  Interpretor\bin\graphic\ParserGraphic.class

     文件        852  2009-12-17 14:13  Interpretor\bin\graphic\ResultWindow.class

     文件       4121  2009-12-17 14:45  Interpretor\bin\graphic\UserGraphic$1.class

     文件        960  2009-12-17 14:45  Interpretor\bin\graphic\UserGraphic$UndoHandler.class

     文件      10124  2009-12-17 14:45  Interpretor\bin\graphic\UserGraphic.class

     文件       7779  2009-12-11 17:04  Interpretor\bin\graphic.rar

     文件       9243  2009-12-17 14:22  Interpretor\bin\lexer\Lexer.class

     文件       1196  2009-12-04 19:53  Interpretor\bin\lexer\Token.class

     文件       1023  2009-12-17 14:20  Interpretor\bin\parser\AddSymbolLeaf.class

     文件       1972  2009-12-17 14:20  Interpretor\bin\parser\arth\ArthTree.class

     文件       1079  2009-12-17 14:20  Interpretor\bin\parser\arth\NumLeaf.class

     文件       1538  2009-12-17 14:20  Interpretor\bin\parser\arth\OtherPartTree.class

     文件       1442  2009-12-17 14:20  Interpretor\bin\parser\arth\OtherTermTree.class

     文件       1972  2009-12-17 14:20  Interpretor\bin\parser\arth\PartTree.class

     文件       3248  2009-12-17 14:20  Interpretor\bin\parser\arth\TermTree.class

     文件       1791  2009-12-17 14:20  Interpretor\bin\parser\arth\VarArrayElementLeaf.class

     文件       1235  2009-12-17 14:20  Interpretor\bin\parser\arth\VarSimpleLeaf.class

     文件       1551  2009-12-17 14:20  Interpretor\bin\parser\ass\AssVarArrayElementTree.class

     文件       1511  2009-12-17 14:20  Interpretor\bin\parser\ass\AssVarSimpleTree.class

     文件        775  2009-12-17 14:20  Interpretor\bin\parser\BlockTree.class

     文件        384  2009-12-17 14:20  Interpretor\bin\parser\CommonTree.class

     文件        332  2009-12-17 14:20  Interpretor\bin\parser\CONSTS.class

     文件       2142  2009-12-17 14:20  Interpretor\bin\parser\declare\VarArrayDefTree.class

     文件       1490  2009-12-17 14:20  Interpretor\bin\parser\declare\VarSimpleDefTree.class

     文件       2060  2009-12-17 14:20  Interpretor\bin\parser\ifTree\IfTree.class

     文件       1838  2009-12-17 14:20  Interpretor\bin\parser\LogicTree.class

............此处省略88个文件信息

评论

共有 条评论