org.antlr.v4.tool.Grammar.getDefaultActionScope()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.antlr.v4.tool.Grammar.getDefaultActionScope()方法的一些代码示例,展示了Grammar.getDefaultActionScope()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grammar.getDefaultActionScope()方法的具体详情如下:
包路径:org.antlr.v4.tool.Grammar
类名称:Grammar
方法名:getDefaultActionScope

Grammar.getDefaultActionScope介绍

[英]Given a grammar type, what should be the default action scope? If I say @members in a COMBINED grammar, for example, the default scope should be "parser".
[中]给定语法类型,默认操作范围是什么?例如,如果我在组合语法中说@members,那么默认范围应该是“parser”。

代码示例

代码示例来源:origin: com.tunnelvisionlabs/antlr4

public void checkActionRedefinitions(List<GrammarAST> actions) {
  if (actions == null) return;
  String scope = g.getDefaultActionScope();
  String name;
  GrammarAST nameNode;
  for (GrammarAST ampersandAST : actions) {
    nameNode = (GrammarAST) ampersandAST.getChild(0);
    if (ampersandAST.getChildCount() == 2) {
      name = nameNode.getText();
    }
    else {
      scope = nameNode.getText();
      name = ampersandAST.getChild(1).getText();
    }
    Set<String> scopeActions = actionScopeToActionNames.get(scope);
    if (scopeActions == null) { // init scope
      scopeActions = new HashSet<String>();
      actionScopeToActionNames.put(scope, scopeActions);
    }
    if (!scopeActions.contains(name)) {
      scopeActions.add(name);
    }
    else {
      errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
          g.fileName, nameNode.token, name);
    }
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public void checkActionRedefinitions(List<GrammarAST> actions) {
  if (actions == null) return;
  String scope = g.getDefaultActionScope();
  String name;
  GrammarAST nameNode;
  for (GrammarAST ampersandAST : actions) {
    nameNode = (GrammarAST) ampersandAST.getChild(0);
    if (ampersandAST.getChildCount() == 2) {
      name = nameNode.getText();
    }
    else {
      scope = nameNode.getText();
      name = ampersandAST.getChild(1).getText();
    }
    Set<String> scopeActions = actionScopeToActionNames.get(scope);
    if (scopeActions == null) { // init scope
      scopeActions = new HashSet<String>();
      actionScopeToActionNames.put(scope, scopeActions);
    }
    if (!scopeActions.contains(name)) {
      scopeActions.add(name);
    }
    else {
      errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
          g.fileName, nameNode.token, name);
    }
  }
}

代码示例来源:origin: org.antlr/antlr4

public void checkActionRedefinitions(List<GrammarAST> actions) {
  if (actions == null) return;
  String scope = g.getDefaultActionScope();
  String name;
  GrammarAST nameNode;
  for (GrammarAST ampersandAST : actions) {
    nameNode = (GrammarAST) ampersandAST.getChild(0);
    if (ampersandAST.getChildCount() == 2) {
      name = nameNode.getText();
    }
    else {
      scope = nameNode.getText();
      name = ampersandAST.getChild(1).getText();
    }
    Set<String> scopeActions = actionScopeToActionNames.get(scope);
    if (scopeActions == null) { // init scope
      scopeActions = new HashSet<String>();
      actionScopeToActionNames.put(scope, scopeActions);
    }
    if (!scopeActions.contains(name)) {
      scopeActions.add(name);
    }
    else {
      errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
          g.fileName, nameNode.token, name);
    }
  }
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

public void checkActionRedefinitions(List<GrammarAST> actions) {
  if ( actions==null ) return;
  String scope = g.getDefaultActionScope();
  String name;
  GrammarAST nameNode;
  for (GrammarAST ampersandAST : actions) {
    nameNode = (GrammarAST)ampersandAST.getChild(0);
    if ( ampersandAST.getChildCount()==2 ) {
      name = nameNode.getText();
    }
    else {
      scope = nameNode.getText();
      name = ampersandAST.getChild(1).getText();
    }
    Set<String> scopeActions = actionScopeToActionNames.get(scope);
    if ( scopeActions==null ) { // init scope
      scopeActions = new HashSet<String>();
      actionScopeToActionNames.put(scope, scopeActions);
    }
    if ( !scopeActions.contains(name) ) {
      scopeActions.add(name);
    }
    else {
      errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
                   g.fileName, nameNode.token, name);
    }
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public void checkActionRedefinitions(List<GrammarAST> actions) {
  if ( actions==null ) return;
  String scope = g.getDefaultActionScope();
  String name;
  GrammarAST nameNode;
  for (GrammarAST ampersandAST : actions) {
    nameNode = (GrammarAST)ampersandAST.getChild(0);
    if ( ampersandAST.getChildCount()==2 ) {
      name = nameNode.getText();
    }
    else {
      scope = nameNode.getText();
      name = ampersandAST.getChild(1).getText();
    }
    Set<String> scopeActions = actionScopeToActionNames.get(scope);
    if ( scopeActions==null ) { // init scope
      scopeActions = new HashSet<String>();
      actionScopeToActionNames.put(scope, scopeActions);
    }
    if ( !scopeActions.contains(name) ) {
      scopeActions.add(name);
    }
    else {
      errMgr.grammarError(ErrorType.ACTION_REDEFINITION,
                   g.fileName, nameNode.token, name);
    }
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

String scopeName = rootGrammar.getDefaultActionScope();
GrammarAST scope, name, action;
if ( at.getChildCount()>2 ) { // must have a scope

代码示例来源:origin: uk.co.nichesolutions/antlr4

String scopeName = rootGrammar.getDefaultActionScope();
GrammarAST scope, name, action;
if ( at.getChildCount()>2 ) { // must have a scope

代码示例来源:origin: com.tunnelvisionlabs/antlr4

String scopeName = rootGrammar.getDefaultActionScope();
GrammarAST scope, name, action;
if ( at.getChildCount()>2 ) { // must have a scope

代码示例来源:origin: io.virtdata/virtdata-lib-realer

String scopeName = rootGrammar.getDefaultActionScope();
GrammarAST scope, name, action;
if ( at.getChildCount()>2 ) { // must have a scope

代码示例来源:origin: org.antlr/antlr4

String scopeName = rootGrammar.getDefaultActionScope();
GrammarAST scope, name, action;
if ( at.getChildCount()>2 ) { // must have a scope

相关文章