platform/packages/symbol_table/example/main.dart

27 lines
885 B
Dart
Raw Normal View History

2021-05-18 12:32:54 +00:00
import 'package:angel3_symbol_table/angel3_symbol_table.dart';
void main(List<String> args) {
2021-06-26 13:13:43 +00:00
//var mySymbolTable = SymbolTable<int>();
2021-05-18 12:32:54 +00:00
var doubles =
SymbolTable<double>(values: {'hydrogen': 1.0, 'avogadro': 6.022e23});
// Create a new variable within the scope.
doubles.create('one');
doubles.create('one', value: 1.0);
doubles.create('one', value: 1.0, constant: true);
// Set a variable within an ancestor, OR create a new variable if none exists.
doubles.assign('two', 2.0);
// Completely remove a variable.
doubles.remove('two');
// Find a symbol, either in this symbol table or an ancestor.
2021-06-26 13:13:43 +00:00
//var symbol1 = doubles.resolve('one');
2021-05-18 12:32:54 +00:00
// Find OR create a symbol.
2021-06-26 13:13:43 +00:00
//var symbol2 = doubles.resolveOrCreate('one');
//var symbol3 = doubles.resolveOrCreate('one', value: 1.0);
//var symbol4 = doubles.resolveOrCreate('one', value: 1.0, constant: true);
2021-05-18 12:32:54 +00:00
}