当前位置: 首页>>代码示例>>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;未经允许,请勿转载。