當前位置: 首頁>>代碼示例>>Java>>正文


Java ASTExpression類代碼示例

本文整理匯總了Java中com.fujitsu.vdmj.ast.expressions.ASTExpression的典型用法代碼示例。如果您正苦於以下問題:Java ASTExpression類的具體用法?Java ASTExpression怎麽用?Java ASTExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ASTExpression類屬於com.fujitsu.vdmj.ast.expressions包,在下文中一共展示了ASTExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readExitStatement

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTStatement readExitStatement(LexLocation token)
	throws ParserException, LexException
{
	checkFor(Token.EXIT, 2190, "Expecting 'exit'");

	try
	{
		reader.push();
		ASTExpression exp = getExpressionReader().readExpression();
		reader.unpush();
		return new ASTExitStatement(token, exp);
	}
	catch (ParserException e)
	{
		reader.pop();
	}

	return new ASTExitStatement(token);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:20,代碼來源:StatementReader.java

示例2: readForIndexStatement

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTStatement readForIndexStatement(LexLocation token)
	throws ParserException, LexException
{
	LexIdentifierToken var = readIdToken("Expecting variable identifier");
	checkFor(Token.EQUALS, 2216, "Expecting '=' after for variable");
	ASTExpression from = getExpressionReader().readExpression();
	checkFor(Token.TO, 2217, "Expecting 'to' after from expression");
	ASTExpression to = getExpressionReader().readExpression();
	ASTExpression by = null;

	if (lastToken().is(Token.BY))
	{
		nextToken();
		by = getExpressionReader().readExpression();
	}

	checkFor(Token.DO, 2218, "Expecting 'do' before loop statement");
	ASTStatement body = getStatementReader().readStatement();
	return new ASTForIndexStatement(token, idToName(var), from, to, by, body);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:21,代碼來源:StatementReader.java

示例3: readConditionalStatement

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTStatement readConditionalStatement(LexLocation token)
	throws ParserException, LexException
{
	ASTExpression exp = getExpressionReader().readExpression();
	checkFor(Token.THEN, 2219, "Missing 'then'");
	ASTStatement thenStmt = readStatement();
	ASTElseIfStatementList elseIfList = new ASTElseIfStatementList();

	while (lastToken().is(Token.ELSEIF))
	{
		LexToken elseif = lastToken();
		nextToken();
		elseIfList.add(readElseIfStatement(elseif.location));
	}

	ASTStatement elseStmt = null;

	if (lastToken().is(Token.ELSE))
	{
		nextToken();
		elseStmt = readStatement();
	}

	return new ASTIfStatement(token, exp, thenStmt, elseIfList, elseStmt);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:26,代碼來源:StatementReader.java

示例4: readAssignmentDefinition

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public ASTAssignmentDefinition readAssignmentDefinition()
	throws ParserException, LexException
{
	LexIdentifierToken name = readIdToken("Expecting variable identifier");
	checkFor(Token.COLON, 2228, "Expecting name:type in declaration");
	ASTType type = getTypeReader().readType();
	ASTExpression exp = null;

	if (lastToken().is(Token.ASSIGN))
	{
		nextToken();
		exp = getExpressionReader().readExpression();
	}
	else if (lastToken().is(Token.EQUALSEQUALS) || lastToken().is(Token.EQUALS))
	{
		throwMessage(2069, "Expecting <identifier>:<type> := <expression>");
	}
	else
	{
		exp = new ASTUndefinedExpression(name.location);
	}

	return new ASTAssignmentDefinition(idToName(name), type, exp);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:25,代碼來源:StatementReader.java

示例5: readLetBeStStatement

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTLetBeStStatement readLetBeStStatement(LexLocation token)
	throws ParserException, LexException
{
	ASTMultipleBind bind = getBindReader().readMultipleBind();
	ASTExpression stexp = null;

	if (lastToken().is(Token.BE))
	{
		nextToken();
		checkFor(Token.ST, 2232, "Expecting 'st' after 'be' in let statement");
		stexp = getExpressionReader().readExpression();
	}

	checkFor(Token.IN, 2233, "Expecting 'in' after bind in let statement");
	return new ASTLetBeStStatement(token, bind, stexp, readStatement());
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:17,代碼來源:StatementReader.java

示例6: readInstanceVariableDefinition

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTDefinition readInstanceVariableDefinition()
throws ParserException, LexException
  {
LexToken token = lastToken();

if (token.is(Token.INV))
{
	nextToken();
	ASTExpression exp = getExpressionReader().readExpression();
	String str = getCurrentModule();
	LexNameToken className = new LexNameToken(str, str, token.location);
	return new ASTClassInvariantDefinition(
		className.getInvName(token.location), exp);
}
else
{
	ASTAccessSpecifier access = readAccessSpecifier(false, false);
	ASTAssignmentDefinition def = getStatementReader().readAssignmentDefinition();
	ASTInstanceVariableDefinition ivd =
		new ASTInstanceVariableDefinition(def.name, def.type, def.expression);
	ivd.setAccessSpecifier(access);
	return ivd;
}
  }
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:25,代碼來源:DefinitionReader.java

示例7: readLetBeStBinding

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTTraceDefinition readLetBeStBinding()
	throws ParserException, LexException
{
	LexToken start = lastToken();
	ASTMultipleBind bind = getBindReader().readMultipleBind();
	ASTExpression stexp = null;

	if (lastToken().is(Token.BE))
	{
		nextToken();
		checkFor(Token.ST, 2232, "Expecting 'st' after 'be' in let statement");
		stexp = getExpressionReader().readExpression();
	}

	checkFor(Token.IN, 2233, "Expecting 'in' after bind in let statement");
	ASTTraceDefinition body = readTraceDefinition();

	return new ASTTraceLetBeStBinding(start.location, bind, stexp, body);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:20,代碼來源:DefinitionReader.java

示例8: ASTImplicitFunctionDefinition

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public ASTImplicitFunctionDefinition(LexNameToken name,
	LexNameList typeParams, ASTPatternListTypePairList parameterPatterns,
	ASTPatternTypePair result,
	ASTExpression body,
	ASTExpression precondition,
	ASTExpression postcondition,
	LexNameToken measure)
{
	super(name.location, name);

	this.typeParams = typeParams;
	this.parameterPatterns = parameterPatterns;
	this.result = result;
	this.body = body;
	this.precondition = precondition;
	this.postcondition = postcondition;
	this.measure = measure;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:19,代碼來源:ASTImplicitFunctionDefinition.java

示例9: ASTTypeDefinition

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public ASTTypeDefinition(LexNameToken name, ASTInvariantType type, ASTPattern invPattern,
	ASTExpression invExpression, ASTPattern eqPattern1, ASTPattern eqPattern2, ASTExpression eqExpression,
	ASTPattern ordPattern1, ASTPattern ordPattern2, ASTExpression ordExpression)
{
	super(name.location, name);

	this.type = type;
	this.invPattern = invPattern;
	this.invExpression = invExpression;
	
	this.eqPattern1 = eqPattern1;
	this.eqPattern2 = eqPattern2;
	this.eqExpression = eqExpression;
	
	this.ordPattern1 = ordPattern1;
	this.ordPattern2 = ordPattern2;
	this.ordExpression = ordExpression;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:19,代碼來源:ASTTypeDefinition.java

示例10: ASTExplicitFunctionDefinition

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public ASTExplicitFunctionDefinition(LexNameToken name, LexNameList typeParams,
	ASTFunctionType type, ASTPatternListList parameters,
	ASTExpression body,
	ASTExpression precondition, ASTExpression postcondition, boolean typeInvariant,
	LexNameToken measure)
{
	super(name.location, name);

	this.typeParams = typeParams;
	this.type = type;
	this.paramPatternList = parameters;
	this.precondition = precondition;
	this.postcondition = postcondition;
	this.body = body;
	this.isTypeInvariant = typeInvariant;
	this.measure = measure;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:18,代碼來源:ASTExplicitFunctionDefinition.java

示例11: ValueBindingObligation

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public ValueBindingObligation(
	ASTPattern p, ASTType t, ASTExpression e, POContextStack ctxt)
{
	super(p.location, POType.VALUE_BINDING, ctxt);
	StringBuilder sb = new StringBuilder();

	sb.append("exists ");
	sb.append(p);
	sb.append(":");
	sb.append(t);
	sb.append(" & ");
	sb.append(p);
	sb.append(" = ");
	sb.append(e);

	value = ctxt.getObligation(sb.toString());
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:18,代碼來源:ValueBindingObligation.java

示例12: parseExpression

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
@Override
protected TCExpression parseExpression(String line, String module) throws Exception
{
	LexTokenReader ltr = new LexTokenReader(line, Settings.dialect, Console.charset);
	ExpressionReader reader = new ExpressionReader(ltr);
	reader.setCurrentModule(module);
	ASTExpression ast = reader.readExpression();
	LexToken end = ltr.getLast();
	
	if (!end.is(Token.EOF))
	{
		throw new ParserException(2330, "Tokens found after expression at " + end, new LexLocation(), 0);
	}

	return ClassMapper.getInstance(TCNode.MAPPINGS).convert(ast);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:17,代碼來源:ClassInterpreter.java

示例13: parseExpression

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
@Override
protected TCExpression parseExpression(String line, String module) throws Exception
{
	LexTokenReader ltr = new LexTokenReader(line, Dialect.VDM_SL, Console.charset);
	ExpressionReader reader = new ExpressionReader(ltr);
	reader.setCurrentModule(getDefaultName());
	ASTExpression ast = reader.readExpression();
	LexToken end = ltr.getLast();
	
	if (!end.is(Token.EOF))
	{
		throw new ParserException(2330, "Tokens found after expression at " + end, new LexLocation(), 0);
	}
	
	return ClassMapper.getInstance(TCNode.MAPPINGS).convert(ast);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:17,代碼來源:ModuleInterpreter.java

示例14: seq_of_char2val_

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
public static Value seq_of_char2val_(Value arg)
{
	ValueList result = new ValueList();

	try
	{
		SeqValue seq = (SeqValue) arg;
		StringBuilder expression = new StringBuilder();
		
		for (Value v: seq.values)
		{
			CharacterValue ch = (CharacterValue) v;
			expression.append(ch.unicode);
		}
		
		LexTokenReader ltr = new LexTokenReader(expression.toString(), Dialect.VDM_PP);
		ExpressionReader reader = new ExpressionReader(ltr);
		reader.setCurrentModule("VDMUtil");
		ASTExpression exp = reader.readExpression();
		TCExpression tcexp = ClassMapper.getInstance(TCNode.MAPPINGS).convert(exp);
		Interpreter ip = Interpreter.getInstance();
		ip.typeCheck(tcexp);
		INExpression inexp = ClassMapper.getInstance(INNode.MAPPINGS).convert(tcexp);

		result.add(new BooleanValue(true));
		Context ctxt = new Context(null, "seq_of_char2val", null);
		ctxt.setThreadState(null);
		result.add(inexp.eval(ctxt));
	}
	catch (Exception e)
	{
		result = new ValueList();
		result.add(new BooleanValue(false));
		result.add(new NilValue());
	}

	return new TupleValue(result);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:39,代碼來源:VDMUtil.java

示例15: readWhileStatement

import com.fujitsu.vdmj.ast.expressions.ASTExpression; //導入依賴的package包/類
private ASTStatement readWhileStatement(LexLocation token)
	throws ParserException, LexException
{
	checkFor(Token.WHILE, 2208, "Expecting 'while'");
	ASTExpression exp = getExpressionReader().readExpression();
	checkFor(Token.DO, 2209, "Expecting 'do' after while expression");
	ASTStatement body = getStatementReader().readStatement();
	return new ASTWhileStatement(token, exp, body);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:10,代碼來源:StatementReader.java


注:本文中的com.fujitsu.vdmj.ast.expressions.ASTExpression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。