Exemplo n.º 1
0
 public AssignStatement(SymbolReference target, Expression value,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.AssignStatement, start, end)
 {
     Target = target;
     Value = value;
 }
Exemplo n.º 2
0
 public ConditionalExpression(Expression cond, Expression first, Expression second, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.ConditionalExpression, start, end)
 {
     Condition = cond;
     TrueExpression = first;
     FalseExpression = second;
 }
Exemplo n.º 3
0
 public Enumeration(String name, List<VariableIdentifier> values,
     SourcePosition start, SourcePosition end)
     : base(name, start, end)
 {
     Type = ASTNodeType.Enumeration;
     Values = values;
 }
Exemplo n.º 4
0
 public InOpReference(InOpDeclaration op, Expression lhs, Expression rhs, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.InOpRef, start, end)
 {
     Operator = op;
     LeftOperand = lhs;
     RightOperand = rhs;
 }
Exemplo n.º 5
0
 public WhileLoop(Expression cond, CodeBody body,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.WhileLoop, start, end)
 {
     Condition = cond;
     Body = body;
 }
Exemplo n.º 6
0
 public ArraySymbolRef(Expression array, Expression index, SourcePosition start, SourcePosition end)
     : base(array, start, end)
 {
     Index = index;
     Type = ASTNodeType.ArrayReference;
     Array = array;
 }
Exemplo n.º 7
0
 public CompositeSymbolRef(Expression outer, Expression inner, SourcePosition start, SourcePosition end)
     : base(inner, start, end)
 {
     InnerSymbol = inner;
     OuterSymbol = outer;
     Type = ASTNodeType.CompositeReference;
 }
Exemplo n.º 8
0
 public void LogError(String msg, SourcePosition start = null, SourcePosition end = null)
 {
     if (start == null && end == null)
         content.Add(new Error(msg));
     else
         content.Add(new LineError(msg, start, end));
 }
Exemplo n.º 9
0
        public bool Equals(SourcePosition p)
        {
            if ((object)p == null)
                return false;

            return (Line == p.Line) && (Column == p.Column) && (CharIndex == p.CharIndex);
        }
Exemplo n.º 10
0
 public SwitchStatement(Expression expr, CodeBody body,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.SwitchStatement, start, end)
 {
     Expression = expr;
     Body = body;
 }
Exemplo n.º 11
0
        public void TestKeywordMatcher()
        {
            KeywordMatcher matcher = new KeywordMatcher("invalid", TokenType.INVALID, Delimiters, false);
            StringTokenizer data = new StringTokenizer("+=+//= invalid=invalidinvalid$=");
            SourcePosition streamPos = new SourcePosition(0, 0, 0);

            // Match a basic delimiter keyword
            Assert.AreEqual(Delimiters.Find(m => m.Keyword == "+=").MatchNext(data, ref streamPos, Log).Type, TokenType.AddAssign);
            Assert.AreEqual(data.CurrentItem, "+");
            data.Advance();
            // Assert that the matched token contains the value
            Assert.AreEqual(Delimiters.Find(m => m.Keyword == "/").MatchNext(data, ref streamPos, Log).Value, "/");
            Assert.AreEqual(data.CurrentItem, "/");
            data.Advance(3);
            // Match against a keyword rather than short operator as well as delimiter
            Assert.IsNotNull(matcher.MatchNext(data, ref streamPos, Log));
            Assert.AreEqual(data.CurrentItem, "=");
            data.Advance();
            // Assert that non-delimiters will prevent a match
            Assert.IsNull(matcher.MatchNext(data, ref streamPos, Log));
            Assert.AreEqual(data.CurrentItem, "i");
            data.Advance(14);
            // Ensure EOF with keywords
            Assert.IsNotNull(Delimiters.Find(m => m.Keyword == "$=").MatchNext(data, ref streamPos, Log));

            Assert.IsTrue(data.AtEnd());
        }
Exemplo n.º 12
0
 public IfStatement(Expression cond, CodeBody then,
     SourcePosition start, SourcePosition end, CodeBody optelse = null)
     : base(ASTNodeType.IfStatement, start, end)
 {
     Condition = cond;
     Then = then;
     Else = optelse;
 }
Exemplo n.º 13
0
 public VariableDeclaration(VariableType type, List<Specifier> specs,
     List<VariableIdentifier> names, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.VariableDeclaration, start, end)
 {
     Specifiers = specs;
     VarType = type;
     Variables = names;
 }
Exemplo n.º 14
0
 public PreOpDeclaration(String keyword,
     bool delim, CodeBody body, VariableType returnType,
     FunctionParameter operand, List<Specifier> specs,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.PrefixOperator, keyword, delim, body, returnType, specs, start, end)
 {
     Operand = operand;
 }
Exemplo n.º 15
0
 public Struct(String name, List<Specifier> specs,
     List<VariableDeclaration> members,
     SourcePosition start, SourcePosition end, VariableType parent = null)
     : base(name, start, end)
 {
     Type = ASTNodeType.Struct;
     Specifiers = specs;
     Members = members;
     Parent = parent;
 }
Exemplo n.º 16
0
 public InOpDeclaration(String keyword, int precedence,
 bool delim, CodeBody body, VariableType returnType,
 FunctionParameter leftOp, FunctionParameter rightOp,
 List<Specifier> specs, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.InfixOperator, keyword, delim, body, returnType, specs, start, end)
 {
     LeftOperand = leftOp;
     RightOperand = rightOp;
     Precedence = precedence;
 }
Exemplo n.º 17
0
 public ForLoop(Expression cond, CodeBody body,
     Statement init, Statement update,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.WhileLoop, start, end)
 {
     Condition = cond;
     Body = body;
     Init = init;
     Update = update;
 }
Exemplo n.º 18
0
 public OperatorDeclaration(ASTNodeType type, String keyword, 
     bool delim, CodeBody body, VariableType returnType,
     List<Specifier> specs, SourcePosition start, SourcePosition end)
     : base(type, start, end)
 {
     OperatorKeyword = keyword;
     isDelimiter = delim;
     Body = body;
     ReturnType = returnType;
     Specifiers = specs;
     Locals = new List<VariableDeclaration>();
 }
Exemplo n.º 19
0
 public Function(String name, VariableType returntype, CodeBody body,
     List<Specifier> specs, List<FunctionParameter> parameters,
     SourcePosition start, SourcePosition end)
     : base(ASTNodeType.Function, start, end)
 {
     Name = name;
     Body = body;
     ReturnType = returntype;
     Specifiers = specs;
     Parameters = parameters;
     Locals = new List<VariableDeclaration>();
 }
Exemplo n.º 20
0
 public State(String name, CodeBody body, List<Specifier> specs,
     State parent, List<Function> funcs, List<Function> ignores,
     List<StateLabel> labels, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.State, start, end)
 {
     Name = name;
     Body = body;
     Specifiers = specs;
     Parent = parent;
     Functions = funcs;
     Ignores = ignores;
     Labels = labels;
     Locals = new List<VariableDeclaration>();
 }
Exemplo n.º 21
0
 public Class(String name, List<Specifier> specs, 
     List<VariableDeclaration> vars, List<VariableType> types, List<Function> funcs,
     List<State> states, VariableType parent, VariableType outer, List<OperatorDeclaration> ops,
     SourcePosition start, SourcePosition end)
     : base(name, start, end)
 {
     Parent = parent;
     OuterClass = outer;
     Specifiers = specs;
     VariableDeclarations = vars;
     TypeDeclarations = types;
     Functions = funcs;
     States = states;
     Operators = ops;
     Type = ASTNodeType.Class;
 }
Exemplo n.º 22
0
 public Specifier(String value, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.Specifier, start, end)
 {
     Value = value;
 }
Exemplo n.º 23
0
 public StateLabel(String name, int offset, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.StateLabel, start, end)
 {
     StartOffset = offset;
     Name = name;
 }
Exemplo n.º 24
0
 public IntegerLiteral(int val, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.IntegerLiteral, start, end)
 {
     Value = val;
 }
Exemplo n.º 25
0
 public LineError(String msg, SourcePosition start, SourcePosition end)
     : base(msg, start, end)
 {
 }
Exemplo n.º 26
0
 public LineWarning(String msg, SourcePosition start, SourcePosition end)
     : base(msg, start, end)
 {
 }
Exemplo n.º 27
0
 public StopStatement(SourcePosition start, SourcePosition end)
     : base(ASTNodeType.StopStatement, start, end)
 {
 }
Exemplo n.º 28
0
 public FunctionCall(SymbolReference func, List<Expression> parameters, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.FunctionCall, start, end)
 {
     Function = func;
     Parameters = parameters;
 }
Exemplo n.º 29
0
 public void LogMessage(String msg, SourcePosition start = null, SourcePosition end = null)
 {
     if (start == null && end == null)
         content.Add(new LogMessage(msg));
     else
         content.Add(new PositionedMessage(msg, start, end));
 }
Exemplo n.º 30
0
 public FloatLiteral(float val, SourcePosition start, SourcePosition end)
     : base(ASTNodeType.FloatLiteral, start, end)
 {
     Value = val;
 }