Copyright (c) 2015, Michael Mitterer (firstname.lastname@example.org), IT-Consulting and Development Limited.
All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- An assignment statement evaluates an expression and stores the result in a variable.
- Base interface for an expression. An expression is like a statement except that it also returns a value when executed. Expressions do not appear at the top level in Dasic programs, but are used in many statements. For example, the value printed by a "print" statement is an expression. Unlike statements, expressions can nest.
- A "goto" statement jumps execution to another place in the program.
- An if then statement jumps execution to another place in the program, but only if an expression evaluates to something other than 0.
- An "input" statement reads input from the user and stores it in a variable.
- A numeric value. Dasic uses doubles internally for all numbers.
- An operator expression evaluates two expressions and then performs some arithmetic operation on the results.
- This defines the Dasic parser. The parser takes in a sequence of tokens and generates an abstract syntax tree. This is the nested data structure that represents the series of statements, and the expressions (which can nest arbitrarily deeply) that they evaluate. In technical terms, what we have is a recursive descent parser, the simplest kind to hand-write. [...]
- A "print" statement evaluates an expression, converts the result to a string, and displays it to the user.
- Base interface for a Dasic statement. The different supported statement types like "print" and "goto" implement this.
- A string value.
- This is a single meaningful chunk of code. It is created by the tokenizer and consumed by the parser.
- This is the base interface for a value. Values are the data that the interpreter processes. They are what gets stored in variables, printed, and operated on. [...]
- A variable expression evaluates to the current value stored in that variable.
- This defines the different states the tokenizer can be in while it's scanning through the source code. Tokenizers are state machines, which means the only data they need to store is where they are in the source code and this one "state" or mode value. [...]
- This defines the different kinds of tokens or meaningful chunks of code that the parser knows how to consume. These let us distinguish, for example, between a string "foo" and a variable named "foo". [...]