Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[xtext-dev] sf.net CVS down / needed update for de.itemis.xtext.antlr

Hi,

yesterday I did some small updates to the AntlrGrammar.ext and today the sf.net CVS does not allow an CVS update: https://sourceforge.net/tracker/index.php?func=detail&aid=2682595&group_id=1&atid=200001

The update is required for Xtext to generate working Antlr based parsers. In case you haven't got the update yet, the file is attached.

regards,
 Moritz
/*******************************************************************************
 * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 *******************************************************************************/
import xtext;
import emf;

extension org::eclipse::xtext::generator::grammarAccess::GrammarAccess reexport;
extension org::eclipse::xtext::Extensions reexport;
extension org::eclipse::xtext::GrammarUtil reexport;
extension org::eclipse::xtext::Utilities;

ruleName(ParserRule this) : 'rule'+name;
ruleName(TerminalRule this) : 'RULE_'+name.toUpperCase();
ruleName(AbstractRule this) : "Unsupported";

entryRuleName(ParserRule this) : 'entryRule'+name;

setOrAdd(Action this) : if operator=='+=' then 'add' else 'set';


setOrAdd(Assignment this) : if operator=='+=' then 'add' else 'set';

isCalled(Grammar grammar, ParserRule this) :
	let x = grammar.allParserRules() :
		x.indexOf(this)==0 || 
		x.containingGrammar().eAllContents.flatten().typeSelect(RuleCall).select(call|call.rule!=null).rule.name.contains(this.name);

localVar(Assignment this) : 'lv_'+feature + '_' + containingParserRule().contentsAsList().indexOf(this);
localVar(RuleCall this) : 'this_'+rule.name + '_' + containingParserRule().contentsAsList().indexOf(this);

List[AbstractElement] contentsAsList(xtext::ParserRule this):
	alternatives.contentsAsList();
	
List[AbstractElement] contentsAsList(xtext::AbstractElement this):
	{this};
	
List[AbstractElement] contentsAsList(xtext::Alternatives this):
	this.groups.contentsAsList();

List[AbstractElement] contentsAsList(xtext::Group this):
	this.tokens.contentsAsList();
	
toStringLiteral(xtext::AbstractElement this) :
	"null";
	
String toJavaString(String this):
	JAVA org.eclipse.xtext.util.Strings.convertToJavaString(java.lang.String);

toStringLiteral(RuleCall this) :
	rule!=null ? '"'+this.rule.name+'"' :  "null";

toStringLiteral(Keyword this) :
	'"'+this.value.toJavaString()+'"';
	
String toLexerBody(TerminalRule this):
	JAVA de.itemis.xtext.antlr.TerminalRuleToLexerBody.toLexerBody(org.eclipse.xtext.TerminalRule);
	
String objectURI(Grammar grammar, emf::EObject object) :
	JAVA de.itemis.xtext.antlr.AntlrGrammarGenUtil.getClasspathURI(org.eclipse.xtext.Grammar, org.eclipse.emf.ecore.EObject);

mustBeParenthesized(AbstractElement this) : true;
mustBeParenthesized(Group this) : true;
mustBeParenthesized(Alternatives this) : true;
mustBeParenthesized(Keyword this) : cardinality!=null;
mustBeParenthesized(RuleCall this) : cardinality!=null;

String grammarElementAccess(EObject object):
	"Unsupported : grammarElementAccess for: " + object.toString(); 
	
String grammarElementAccess(AbstractRule this):
	gaRuleAccessor(); 

String grammarElementAccess(AbstractElement element):
	gaRuleElementAccessor(element);

List[String] initialHiddenTokens(Grammar this):
  if (definesHiddenTokens) then 
  	hiddenTokens.ruleName() 
  else if (usedGrammars.size == 1) then 
  	initialHiddenTokens(usedGrammars.first()) 
  else {};

Back to the top