List of usage examples for org.antlr.v4.runtime Token getText
String getText();
From source file:edu.clemson.cs.r2jt.typeandpopulate2.PopulatingVisitor.java
License:Open Source License
/** * <p>For a given <code>AbstractFunctionExp</code>, finds the entry in the * symbol table to which it refers. For a complete discussion of the * algorithm used, see//www. j av a2 s . c o m * <a href="http://sourceforge.net/apps/mediawiki/resolve/index.php?title=Package_Search_Algorithm"> * Package Search Algorithm</a>.</p> */ private MathSymbolEntry getIntendedFunction(MathSymbolAST e) { //TODO : All this logic should be encapsulated into a SymbolQuery called // MathFunctionQuery. MTFunction eType = e.getConservativePreApplicationType(myTypeGraph); Token eOperator = e.getName(); String eOperatorString = eOperator.getText(); List<MathSymbolEntry> sameNameFunctions = myBuilder.getInnermostActiveScope() .query(new MathFunctionNamedQuery(e.getQualifier(), eOperator)); if (sameNameFunctions.isEmpty()) { throw new SrcErrorException("no such function ", e.getName()); } MathSymbolEntry intendedEntry; try { intendedEntry = getExactDomainTypeMatch(e, sameNameFunctions); } catch (NoSolutionException nse) { try { intendedEntry = getInexactDomainTypeMatch(e, sameNameFunctions); } catch (NoSolutionException nsee2) { boolean foundOne = false; String errorMessage = "no function applicable for " + "domain: " + eType.getDomain() + "\n\ncandidates:\n"; for (SymbolTableEntry entry : sameNameFunctions) { if (entry instanceof MathSymbolEntry && ((MathSymbolEntry) entry).getType() instanceof MTFunction) { errorMessage += "\t" + entry.getName() + " : " + ((MathSymbolEntry) entry).getType() + "\n"; foundOne = true; } } if (!foundOne) { throw new SrcErrorException("no such function ", e.getStart()); } throw new SrcErrorException(errorMessage, e.getStart()); } } if (intendedEntry.getDefiningElement() == myCurrentDirectDefinition) { throw new SrcErrorException("direct definition cannot " + "contain recursive call ", e.getStart()); } MTFunction intendedEntryType = (MTFunction) intendedEntry.getType(); PopulatingVisitor.emitDebug("matching " + eOperator + " : " + eType + " to " + intendedEntry.getName() + " : " + intendedEntryType); return intendedEntry; }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.PopulatingVisitor.java
License:Open Source License
public void noSuchSymbol(Token qualifier, Token symbol) { String message;/*from w ww .ja va 2 s . c om*/ if (qualifier == null) { message = "no such symbol " + symbol.getText(); throw new SrcErrorException(message, symbol); } else { message = "no such symbol in module " + qualifier.getText() + "." + symbol.getText(); throw new SrcErrorException(message, qualifier); } }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.PopulatingVisitor.java
License:Open Source License
public <T extends SymbolTableEntry> void ambiguousSymbol(Token symbol, List<T> candidates) { String message = "ambiguous symbol; candidates: "; boolean first = true; for (SymbolTableEntry candidate : candidates) { if (first) { first = false;/* w ww . j ava 2s .c o m*/ } else { message += ", "; } message += candidate.getSourceModuleIdentifier().fullyQualifiedRepresentation(symbol.getText()); } throw new SrcErrorException(message, symbol); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.PopulatingVisitor.java
License:Open Source License
public void duplicateSymbol(Token symbol) { throw new SrcErrorException("duplicate symbol: " + symbol.getText(), symbol); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.PopulatingVisitor.java
License:Open Source License
private SymbolTableEntry addBinding(Token name, SymbolTableEntry.Quantification q, ResolveAST definingElement, MTType type, MTType typeValue, Map<String, MTType> schematicTypes) { if (type == null) { throw new NullPointerException(); } else {/*www . jav a 2s. c om*/ try { return myBuilder.getInnermostActiveScope().addBinding(name.getText(), q, definingElement, type, typeValue, schematicTypes, myGenericTypes); } catch (DuplicateSymbolException dse) { duplicateSymbol(name); throw new RuntimeException(); //This will never fire } } }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.query.MathSymbolQuery.java
License:Open Source License
public MathSymbolQuery(Token qualifier, Token name) { this(qualifier, name.getText(), name); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.query.NameAndEntryTypeQuery.java
License:Open Source License
public NameAndEntryTypeQuery(Token qualifier, Token name, Class<? extends SymbolTableEntry> entryType, ImportStrategy importStrategy, FacilityStrategy facilityStrategy, boolean localPriority) { this(qualifier, name.getText(), entryType, importStrategy, facilityStrategy, localPriority); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.query.NameQuery.java
License:Open Source License
public NameQuery(Token qualifier, Token name, ImportStrategy importStrategy, FacilityStrategy facilityStrategy, boolean localPriority) { this(qualifier, name.getText(), importStrategy, facilityStrategy, localPriority); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.query.ProgramVariableQuery.java
License:Open Source License
public ProgramVariableQuery(Token qualifier, Token name) { this(qualifier, name.getText(), name); }
From source file:edu.clemson.cs.r2jt.typeandpopulate2.searchers.OperationSearcher.java
License:Open Source License
public OperationSearcher(Token name, List<PTType> argumentTypes) { myQueryName = name.getText(); myQueryLocation = name;/* ww w. j a v a2s . c o m*/ myActualArgumentTypes = new LinkedList<PTType>(argumentTypes); }