transitions.java

来自「有关编译器的编译器.」· Java 代码 · 共 93 行

JAVA
93
字号
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of SableCC.                             * * See the file "LICENSE" for copyright information and the  * * terms and conditions for copying, distribution and        * * modification of SableCC.                                  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */package org.sablecc.sablecc;import org.sablecc.sablecc.analysis.*;import org.sablecc.sablecc.node.*;import java.util.*;public class Transitions extends DepthFirstAdapter{  public final Map tokenStates = new TypedHashMap(                                   NodeCast.instance,                                   NoCast.instance);  private String state;  private String transition;  private Map map;  public void caseAStateList(AStateList node)  {    inAStateList(node);    if(node.getLBrace() != null)    {      node.getLBrace().apply(this);    }    if(node.getId() != null)    {      node.getId().apply(this);    }    if(node.getTransition() != null)    {      node.getTransition().apply(this);    }    outAStateList(node);  // We moved this...    {      Object temp[] = node.getStateLists().toArray();      for(int i = 0; i < temp.length; i++)      {        ((PStateListTail) temp[i]).apply(this);      }    }    if(node.getRBrace() != null)    {      node.getRBrace().apply(this);    }  }  public void inATokenDef(ATokenDef node)  {    map = new TypedTreeMap(            StringComparator.instance,            StringCast.instance,            StringCast.instance);  }  public void inAStateList(AStateList node)  {    state = transition = node.getId().getText().toUpperCase();  }  public void inAStateListTail(AStateListTail node)  {    state = transition = node.getId().getText().toUpperCase();  }  public void outATransition(ATransition node)  {    transition = node.getId().getText().toUpperCase();  }  public void outAStateList(AStateList node)  {    map.put(state, transition);  }  public void outAStateListTail(AStateListTail node)  {    map.put(state, transition);  }  public void outATokenDef(ATokenDef node)  {    tokenStates.put(node, map);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?