mirror of
https://github.com/Ed94/LangStudies.git
synced 2025-01-21 20:13:45 -08:00
EoI : Lectures 1-5 complete
This commit is contained in:
parent
9eba81139d
commit
f85c9615e4
BIN
App/Assets/Branding/EoI_Class_Cover.png
Normal file
BIN
App/Assets/Branding/EoI_Class_Cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 193 KiB |
35
App/Assets/Branding/EoI_Class_Cover.png.import
Normal file
35
App/Assets/Branding/EoI_Class_Cover.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/EoI_Class_Cover.png-180761d77f8e0fd8967a2d9e7fc7462a.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/Branding/EoI_Class_Cover.png"
|
||||
dest_files=[ "res://.import/EoI_Class_Cover.png-180761d77f8e0fd8967a2d9e7fc7462a.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -1,4 +1,4 @@
|
||||
[gd_resource type="StyleBoxFlat" format=2]
|
||||
|
||||
[resource]
|
||||
bg_color = Color( 0.0941176, 0.0666667, 0.137255, 1 )
|
||||
bg_color = Color( 0.12549, 0.0823529, 0.0862745, 1 )
|
4
App/Assets/Styles/Editor.Purple.SytleBoxFlat.tres
Normal file
4
App/Assets/Styles/Editor.Purple.SytleBoxFlat.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="StyleBoxFlat" format=2]
|
||||
|
||||
[resource]
|
||||
bg_color = Color( 0.12549, 0.109804, 0.164706, 1 )
|
4
App/Assets/Styles/Editor.Wine.SytleBoxFlat.tres
Normal file
4
App/Assets/Styles/Editor.Wine.SytleBoxFlat.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="StyleBoxFlat" format=2]
|
||||
|
||||
[resource]
|
||||
bg_color = Color( 0.164706, 0.109804, 0.117647, 1 )
|
@ -1,6 +1,6 @@
|
||||
[gd_resource type="Theme" load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Styles/Editor.SytleBoxFlat.tres" type="StyleBox" id=1]
|
||||
[ext_resource path="res://Assets/Styles/Editor.Purple.SytleBoxFlat.tres" type="StyleBox" id=1]
|
||||
[ext_resource path="res://Assets/Fonts/DF_RecMonoSemiCasul.tres" type="DynamicFont" id=2]
|
||||
[ext_resource path="res://Assets/Styles/Editor.SytleBoxFlat.Inactive.tres" type="StyleBox" id=3]
|
||||
|
15
App/Assets/Styles/Wine.EditorTheme.tres
Normal file
15
App/Assets/Styles/Wine.EditorTheme.tres
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_resource type="Theme" load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Styles/Editor.Wine.SytleBoxFlat.tres" type="StyleBox" id=1]
|
||||
[ext_resource path="res://Assets/Fonts/DF_RecMonoSemiCasul.tres" type="DynamicFont" id=2]
|
||||
[ext_resource path="res://Assets/Styles/Editor.SytleBoxFlat.Inactive.tres" type="StyleBox" id=3]
|
||||
[ext_resource path="res://Assets/Styles/Editor.DarkWine.SytleBoxFlat.tres" type="StyleBox" id=4]
|
||||
|
||||
[resource]
|
||||
Button/styles/disabled = ExtResource( 3 )
|
||||
Panel/styles/panel = ExtResource( 1 )
|
||||
TextEdit/colors/font_color = Color( 1, 1, 1, 1 )
|
||||
TextEdit/colors/font_color_readonly = Color( 1, 1, 1, 1 )
|
||||
TextEdit/fonts/font = ExtResource( 2 )
|
||||
TextEdit/styles/normal = ExtResource( 4 )
|
||||
TextEdit/styles/read_only = ExtResource( 4 )
|
93
App/EoI/EoI_Viewer.tscn
Normal file
93
App/EoI/EoI_Viewer.tscn
Normal file
@ -0,0 +1,93 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Styles/Purple.EditorTheme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Assets/Branding/EoI_Class_Cover.png" type="Texture" id=2]
|
||||
[ext_resource path="res://EoI/Scripts/EoI_Viewer.gd" type="Script" id=4]
|
||||
[ext_resource path="res://Assets/Styles/Wine.EditorTheme.tres" type="Theme" id=5]
|
||||
|
||||
[node name="EoI_Panel" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 5 )
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="CourseBrand" type="TextureRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_scale = Vector2( 0.2, 0.2 )
|
||||
texture = ExtResource( 2 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="Letter_FDialog" type="FileDialog" parent="."]
|
||||
anchor_left = 0.35
|
||||
anchor_top = 0.15
|
||||
anchor_right = 0.45
|
||||
anchor_bottom = 0.25
|
||||
margin_right = 356.0
|
||||
margin_bottom = 373.0
|
||||
theme = ExtResource( 1 )
|
||||
popup_exclusive = true
|
||||
window_title = "Open a File"
|
||||
mode = 0
|
||||
access = 2
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_top = 0.196
|
||||
anchor_right = 0.2
|
||||
anchor_bottom = 1.0
|
||||
margin_top = 2.39999
|
||||
margin_right = -1.8
|
||||
margin_bottom = -2.0
|
||||
|
||||
[node name="Eva_Interpret_Btn" type="Button" parent="VBox"]
|
||||
margin_right = 203.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( -123, -302 )
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.08
|
||||
theme = ExtResource( 1 )
|
||||
text = "Eva: Interpret"
|
||||
|
||||
[node name="Separator" type="HSeparator" parent="VBox"]
|
||||
modulate = Color( 0.145098, 0.145098, 0.164706, 0 )
|
||||
margin_top = 36.0
|
||||
margin_right = 203.0
|
||||
margin_bottom = 441.0
|
||||
size_flags_vertical = 15
|
||||
theme = ExtResource( 5 )
|
||||
|
||||
[node name="Back_Btn" type="Button" parent="VBox"]
|
||||
margin_top = 445.0
|
||||
margin_right = 203.0
|
||||
margin_bottom = 478.0
|
||||
rect_pivot_offset = Vector2( -123, -302 )
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.08
|
||||
theme = ExtResource( 1 )
|
||||
text = "Course Directory"
|
||||
|
||||
[node name="Editor_TEdit" type="TextEdit" parent="."]
|
||||
anchor_left = 0.2
|
||||
anchor_right = 0.625
|
||||
anchor_bottom = 0.8
|
||||
theme = ExtResource( 5 )
|
||||
show_line_numbers = true
|
||||
draw_tabs = true
|
||||
highlight_all_occurrences = true
|
||||
smooth_scrolling = true
|
||||
minimap_draw = true
|
||||
|
||||
[node name="Output_TEdit" type="TextEdit" parent="."]
|
||||
anchor_left = 0.2
|
||||
anchor_top = 0.8
|
||||
anchor_right = 0.625
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 0.199997
|
||||
theme = ExtResource( 5 )
|
||||
|
||||
[node name="Debug_TEdit" type="TextEdit" parent="."]
|
||||
anchor_left = 0.625
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 5 )
|
110
App/EoI/Lectures/Lecture.1.2.3.Notes.md
Normal file
110
App/EoI/Lectures/Lecture.1.2.3.Notes.md
Normal file
@ -0,0 +1,110 @@
|
||||
# Pipeline
|
||||
|
||||
Interpretation Involves **RUNTIME SEMANTICS**
|
||||
|
||||
***THE MEANING OF THE PROGRAM MODEL***
|
||||
|
||||
Compliation delegates semantics of runtime behavior to
|
||||
***a TARGET language***
|
||||
|
||||
Interpetation deals with the semantics itself.
|
||||
|
||||
Types of Interpreter **implementation**:
|
||||
* AST-based (recursive)
|
||||
* Bytecode (Virtual Machines)
|
||||
|
||||
Types of Compiler **implementation**:
|
||||
* Ahead-of-time (AOT)
|
||||
* Just-in-time (JIT)
|
||||
|
||||
## Interpeter-AST:
|
||||
|
||||
**Translation Stage:**
|
||||
1. Program Model
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
|
||||
**Runtime Stage:**
|
||||
4. Interpeter
|
||||
5. Runtime Behavior
|
||||
|
||||
## Interpreter-Bytecode:
|
||||
|
||||
**Translation Stage:**
|
||||
1. Program Model
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
4. Bytecode Emitter
|
||||
5. Bytecode instructions primed.
|
||||
|
||||
**Runtime Stage:**
|
||||
6. Interpreter
|
||||
7. Runtime Behavior
|
||||
|
||||
|
||||
**Types of Virtual Machine behavior:**
|
||||
* Stack based
|
||||
* Stack for operands and operators
|
||||
* Result is always on top of stack
|
||||
* Register based
|
||||
* Virtual registers
|
||||
* Result in accumulation register
|
||||
* Map to real via register allocation
|
||||
|
||||
## Compiler Ahead-of-Time:
|
||||
1. Program Model
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
4. Code Generator
|
||||
5. Intermediate representation primed
|
||||
6. Target machine instruction set code generation
|
||||
7. Target machine is intended interpretation platform.
|
||||
8. Runtime Behavior.
|
||||
|
||||
|
||||
## Compiler with LLVM platform:
|
||||
1. Program Model
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
4. LLVM IR generator
|
||||
5. LLVM Native code generator
|
||||
6. Target machine is intended interpretation platform
|
||||
7. Runtime Behavior.
|
||||
|
||||
|
||||
Lexer, and parser are considered **FRONT-END**.
|
||||
Code Generation or byte-code gen or interpreter ast impelementation gen
|
||||
for target instruction platform is considered **BACK-END**.
|
||||
|
||||
|
||||
## Jit Compiler:
|
||||
1. Program Model
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
4. Bytecode Emitter
|
||||
5. Bytecode fed to interpeter
|
||||
6. Interetor may code gen immediately to target hardware platform or interpret ast directly.
|
||||
7. Runtime Behavior.
|
||||
|
||||
## Transpiler:
|
||||
1. Program Model in input langauge
|
||||
2. Lexer: Processing into token elements for a parser.
|
||||
* Output : Tokens
|
||||
3. Parser: Syntactic Analysis
|
||||
* Output : Abstract Syntax Tree (AST)
|
||||
4. AST Transformation to target AST
|
||||
5. Code generation
|
||||
6. Program Model in output langauge
|
||||
|
||||
|
||||
|
45
App/EoI/Lectures/Lecture.4.Notes.md
Normal file
45
App/EoI/Lectures/Lecture.4.Notes.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Eva Programming Langauge
|
||||
|
||||
Dynamic programming langauge.
|
||||
|
||||
Simple syntax, functional heart, OOP support.
|
||||
|
||||
## Eva Expressions:
|
||||
```
|
||||
(<type> <op1> <op2> ... <opN>)
|
||||
```
|
||||
|
||||
Example:
|
||||
```
|
||||
(+ 5 10)
|
||||
(set x 15)
|
||||
|
||||
(if (> x 10)
|
||||
(print "ok")
|
||||
(print "error")
|
||||
)
|
||||
```
|
||||
|
||||
```
|
||||
(def foo (bar)
|
||||
(+ bar 10)
|
||||
)
|
||||
```
|
||||
|
||||
```
|
||||
(lambda (x) (* x x) 10)
|
||||
```
|
||||
|
||||
## Design Goals
|
||||
|
||||
* Simple syntax: S-Expression
|
||||
* Everything is an expression
|
||||
* No explicit return, last evalulated expression is the result
|
||||
* First class functions
|
||||
* Static scope: all functions are closures
|
||||
* Lambda functions
|
||||
* Funcitonal programming
|
||||
* Imperative programming
|
||||
* Namespaces and modules
|
||||
* OOP: Class or prototype based.
|
||||
|
0
App/EoI/Lectures/Lecture.6.Notes.md
Normal file
0
App/EoI/Lectures/Lecture.6.Notes.md
Normal file
@ -0,0 +1,38 @@
|
||||
extends Node
|
||||
|
||||
var eva = preload("Eva.gd").new()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# UX --------------------------------------------------------
|
||||
onready var Editor = get_node("Editor_TEdit")
|
||||
onready var Output = get_node("Output_TEdit")
|
||||
onready var Eva_Btn = get_node("VBox/Eva_Interpret_Btn")
|
||||
onready var Back_Btn = get_node("VBox/Back_Btn")
|
||||
|
||||
|
||||
func evaBtn_pressed():
|
||||
eva.init(Editor.text)
|
||||
|
||||
var ast = eva.parse()
|
||||
|
||||
Output.text = eva.eval(ast)
|
||||
|
||||
func backBtn_pressed():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _ready():
|
||||
Eva_Btn.connect("pressed", self, "evaBtn_pressed")
|
||||
Back_Btn.connect("pressed", self, "backBtn_pressed")
|
316
App/EoI/Scripts/Eva.gd
Normal file
316
App/EoI/Scripts/Eva.gd
Normal file
@ -0,0 +1,316 @@
|
||||
extends Object
|
||||
|
||||
var SRegEx = preload("res://RegM/Scripts/SRegex.gd").new()
|
||||
|
||||
|
||||
const TType : Dictionary = \
|
||||
{
|
||||
fmt_S = "Formatting",
|
||||
cmt_SL = "Comment Single-Line",
|
||||
cmt_ML = "Comment Multi-Line",
|
||||
|
||||
def_Start = "Expression Start",
|
||||
def_End = "Expression End",
|
||||
|
||||
literal_Number = "LIteral: Number",
|
||||
literal_String = "Literal: String",
|
||||
|
||||
operator = "Operator"
|
||||
}
|
||||
|
||||
const Spec : Dictionary = \
|
||||
{
|
||||
TType.cmt_SL : "start // inline.repeat(0-)",
|
||||
TType.cmt_ML : "start /* set(whitespace !whitespace).repeat(0-).lazy */",
|
||||
|
||||
TType.fmt_S : "start whitespace.repeat(1-).lazy",
|
||||
|
||||
TType.def_Start : "start \\(",
|
||||
TType.def_End : "start \\)",
|
||||
|
||||
TType.literal_Number : \
|
||||
"""start
|
||||
set(+ \\-).repeat(0-1)
|
||||
( set(0-9).repeat(1-) \\. ).repeat(0-1)
|
||||
set(0-9).repeat(1-)
|
||||
""",
|
||||
TType.literal_String : "start \\\" !set( \\\" ).repeat(0-) \\\" ",
|
||||
|
||||
TType.operator : "start set(+ \\-)",
|
||||
}
|
||||
|
||||
class Token:
|
||||
var Type : String
|
||||
var Value : String
|
||||
|
||||
func is_Literal():
|
||||
return Type == TType.literal_Number || Type == TType.literal_String;
|
||||
|
||||
|
||||
var SourceText : String
|
||||
var Cursor : int
|
||||
var SpecRegex : Dictionary
|
||||
var Tokens : Array
|
||||
var TokenIndex : int = 0
|
||||
|
||||
|
||||
func compile_regex():
|
||||
for type in TType.values() :
|
||||
var \
|
||||
regex = RegEx.new()
|
||||
regex.compile( SRegEx.transpile(Spec[type]) )
|
||||
|
||||
SpecRegex[type] = regex
|
||||
|
||||
func init(programSrcText):
|
||||
SourceText = programSrcText
|
||||
Cursor = 0
|
||||
TokenIndex = 0
|
||||
|
||||
if SpecRegex.size() == 0 :
|
||||
compile_regex()
|
||||
|
||||
tokenize()
|
||||
|
||||
func next_Token():
|
||||
|
||||
var nextToken = null
|
||||
|
||||
if Tokens.size() > TokenIndex :
|
||||
nextToken = Tokens[TokenIndex]
|
||||
TokenIndex += 1
|
||||
|
||||
return nextToken
|
||||
|
||||
func reached_EndOfText():
|
||||
return Cursor >= SourceText.length()
|
||||
|
||||
func tokenize():
|
||||
Tokens.clear()
|
||||
|
||||
while reached_EndOfText() == false :
|
||||
var srcLeft = SourceText.substr(Cursor)
|
||||
var token = Token.new()
|
||||
|
||||
var error = true
|
||||
for type in TType.values() :
|
||||
var result = SpecRegex[type].search( srcLeft )
|
||||
if result == null || result.get_start() != 0 :
|
||||
continue
|
||||
|
||||
# Skip Comments
|
||||
if type == TType.cmt_SL || type == TType.cmt_ML :
|
||||
Cursor += result.get_string().length()
|
||||
error = false
|
||||
break
|
||||
|
||||
# Skip Whitespace
|
||||
if type == TType.fmt_S :
|
||||
var addVal = result.get_string().length()
|
||||
|
||||
Cursor += addVal
|
||||
error = false
|
||||
break
|
||||
|
||||
token.Type = type
|
||||
token.Value = result.get_string()
|
||||
Cursor += ( result.get_string().length() )
|
||||
|
||||
Tokens.append( token )
|
||||
|
||||
error = false
|
||||
break;
|
||||
|
||||
if error :
|
||||
var assertStrTmplt = "next_token: Source text not understood by tokenizer at Cursor pos: {value} -: {txt}"
|
||||
var assertStr = assertStrTmplt.format({"value" : Cursor, "txt" : srcLeft})
|
||||
assert(true != true, assertStr)
|
||||
return
|
||||
# ---------------------------------------------------------- Lexer
|
||||
|
||||
|
||||
# ---------------------------------------------------------- Parser
|
||||
# ---------------------------------------------------------- AST Node
|
||||
|
||||
const NType = \
|
||||
{
|
||||
literal_Number = "Literal: Number",
|
||||
literal_String = "Literal: String",
|
||||
|
||||
op_Add = "+",
|
||||
op_Mult = "*"
|
||||
}
|
||||
|
||||
class ASTNode:
|
||||
var Data : Array
|
||||
|
||||
func add_Expr( expr ):
|
||||
Data.append(expr)
|
||||
|
||||
func add_TokenValue( token ):
|
||||
Data.append( token.Value )
|
||||
|
||||
func set_Type( nType ):
|
||||
Data.append(nType)
|
||||
|
||||
func arg( id ):
|
||||
return Data[id]
|
||||
|
||||
func num_args():
|
||||
return Data.size() - 1
|
||||
|
||||
func type():
|
||||
return Data[0]
|
||||
|
||||
func is_Number():
|
||||
return type() == NType.literal_Number
|
||||
|
||||
func is_String():
|
||||
return type() == NType.literal_String
|
||||
|
||||
func string():
|
||||
return arg(1).substr(1, arg(1).length() -2)
|
||||
|
||||
|
||||
# Serialization ----------------------------------------------------
|
||||
func array_Serialize(array, fn_objSerializer) :
|
||||
var result = []
|
||||
|
||||
for entry in array :
|
||||
if typeof(entry) == TYPE_ARRAY :
|
||||
result.append( array_Serialize( entry, fn_objSerializer ))
|
||||
|
||||
elif typeof(entry) == TYPE_OBJECT :
|
||||
fn_objSerializer.set_instance(entry)
|
||||
result.append( fn_objSerializer.call_func() )
|
||||
|
||||
else :
|
||||
result.append( entry )
|
||||
|
||||
return result
|
||||
|
||||
func to_SExpression():
|
||||
# var expression = []
|
||||
|
||||
# if typeof(Value) == TYPE_ARRAY :
|
||||
var \
|
||||
to_SExpression_Fn = FuncRef.new()
|
||||
to_SExpression_Fn.set_function("to_SExpression")
|
||||
|
||||
return array_Serialize( self.Data, to_SExpression_Fn )
|
||||
|
||||
# if typeof(Value) == TYPE_OBJECT :
|
||||
# var result = [ Type, Value.to_SExpression() ]
|
||||
# return result
|
||||
|
||||
# expression.append(Value)
|
||||
# return expression
|
||||
# Serialization END -------------------------------------------------
|
||||
|
||||
# ---------------------------------------------------------- AST Node END
|
||||
|
||||
var TokenType : Token
|
||||
var NextToken : Token
|
||||
|
||||
# Gets the next token only if the current token is the specified intended token (tokenType)
|
||||
func eat(tokenType):
|
||||
var currToken = NextToken
|
||||
|
||||
assert(currToken != null, "eat: NextToken was null")
|
||||
|
||||
var assertStrTmplt = "eat: Unexpected token: {value}, expected: {type}"
|
||||
var assertStr = assertStrTmplt.format({"value" : currToken.Value, "type" : tokenType})
|
||||
|
||||
assert(currToken.Type == tokenType, assertStr)
|
||||
|
||||
NextToken = next_Token()
|
||||
|
||||
return currToken
|
||||
|
||||
func parse():
|
||||
NextToken = next_Token()
|
||||
|
||||
if NextToken.Type == TType.def_Start:
|
||||
return parse_Expression()
|
||||
|
||||
if NextToken.is_Literal():
|
||||
return parse_Literal()
|
||||
|
||||
func parse_Expression():
|
||||
eat(TType.def_Start)
|
||||
var node : ASTNode
|
||||
|
||||
if NextToken.Type == TType.operator:
|
||||
node = parse_Operator()
|
||||
|
||||
var arg = 1
|
||||
while NextToken.Type != TType.def_End:
|
||||
node.add_Expr( parse_Literal() )
|
||||
|
||||
if NextToken.is_Literal():
|
||||
node = parse_Literal()
|
||||
|
||||
eat(TType.def_End)
|
||||
|
||||
return node
|
||||
|
||||
func parse_Operator():
|
||||
var \
|
||||
node = ASTNode.new()
|
||||
|
||||
match NextToken.Value:
|
||||
NType.op_Add:
|
||||
node.set_Type(NType.op_Add)
|
||||
NType.op_Mult:
|
||||
node.set_Type(NType.op_Mult)
|
||||
|
||||
eat(TType.operator)
|
||||
|
||||
return node
|
||||
|
||||
func parse_Literal():
|
||||
var \
|
||||
node = ASTNode.new()
|
||||
|
||||
match NextToken.Type:
|
||||
TType.literal_Number:
|
||||
node.set_Type(NType.literal_Number)
|
||||
node.add_TokenValue(NextToken)
|
||||
|
||||
eat(TType.literal_Number)
|
||||
|
||||
TType.literal_String:
|
||||
node.set_Type(NType.literal_String)
|
||||
node.add_TokenValue(NextToken)
|
||||
|
||||
eat(TType.literal_String)
|
||||
|
||||
return node
|
||||
|
||||
# ---------------------------------------------------------- Parser END
|
||||
|
||||
class_name Eva
|
||||
|
||||
# ---------------------------------------------------------- GLOBALS
|
||||
|
||||
# ---------------------------------------------------------- GLOBALS END
|
||||
|
||||
# ---------------------------------------------------------- UTILITIES
|
||||
|
||||
func throw( message ):
|
||||
assert(false, message)
|
||||
# ---------------------------------------------------------- UTILITIES END
|
||||
|
||||
func eval( ast ):
|
||||
if ast.is_Number() :
|
||||
return float(ast.arg(1))
|
||||
if ast.is_String() :
|
||||
return ast.string()
|
||||
|
||||
if ast.type() == NType.op_Add:
|
||||
return String(eval( ast.arg(1) ) + eval( ast.arg(2) ))
|
||||
|
||||
if ast.type() == NType.op_Mult:
|
||||
return String(eval( ast.arg(1) ) * eval( ast.arg(2) ))
|
||||
|
||||
throw("Unimplemented")
|
5
App/EoP/EoP_Viewer.tscn
Normal file
5
App/EoP/EoP_Viewer.tscn
Normal file
@ -0,0 +1,5 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Styles/EditorTheme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Assets/Styles/Purple.EditorTheme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Assets/Branding/RDP_Class_cover_small.png" type="Texture" id=2]
|
||||
[ext_resource path="res://RDP/Scripts/RDP_Viewer.gd" type="Script" id=3]
|
||||
|
||||
@ -11,6 +11,7 @@ margin_left = -9.0
|
||||
margin_top = 1.0
|
||||
margin_right = -9.0
|
||||
margin_bottom = 1.0
|
||||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="CourseBrand" type="TextureRect" parent="."]
|
||||
|
17
App/RegM/Readme.md
Normal file
17
App/RegM/Readme.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Automata: RegEx Machines
|
||||
|
||||
![Img](https://i.imgur.com/NWwBjhN.png)
|
||||
|
||||
## Lectures
|
||||
|
||||
Contains notes taken from the lecture vods.
|
||||
|
||||
## Scripts
|
||||
|
||||
Contains some implementation from the lectures but I have no completed it yet...
|
||||
|
||||
I made my own context-free version of the language callled "SRegEx"
|
||||
This is mainly what I wanted at the end of the day...
|
||||
|
||||
Currently the script only translates to RegEx,
|
||||
I still need to make RegEx to SRegEx
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Branding/RegM_Class_cover_small.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Assets/Styles/EditorTheme.tres" type="Theme" id=2]
|
||||
[ext_resource path="res://Assets/Styles/Purple.EditorTheme.tres" type="Theme" id=2]
|
||||
[ext_resource path="res://RegM/Scripts/RegM_Viewer.gd" type="Script" id=3]
|
||||
|
||||
[node name="RegM_Panel" type="Panel"]
|
||||
|
@ -257,7 +257,7 @@ class ASTNode:
|
||||
}
|
||||
return result
|
||||
|
||||
const NodeType = \
|
||||
const NodeType : Dictionary = \
|
||||
{
|
||||
expression = "Expression",
|
||||
|
||||
@ -1074,4 +1074,3 @@ func transpile_OpNot(node : ASTNode):
|
||||
result += transpile_Set(entry, true)
|
||||
|
||||
return result
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Scripts/CourseDirectory.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/Branding/RDP_Class_cover_small.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Assets/Branding/RegM_Class_cover_small.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Assets/Styles/EditorTheme.tres" type="Theme" id=4]
|
||||
[ext_resource path="res://Assets/Styles/Purple.EditorTheme.tres" type="Theme" id=4]
|
||||
[ext_resource path="res://Assets/Branding/EoI_Class_Cover.png" type="Texture" id=5]
|
||||
|
||||
[node name="Panel" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
@ -16,16 +17,16 @@ anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -452.0
|
||||
margin_top = -125.5
|
||||
margin_top = -80.5
|
||||
margin_right = 452.0
|
||||
margin_bottom = 125.5
|
||||
margin_bottom = 80.5
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="RDP_Btn" type="Button" parent="HBox"]
|
||||
margin_right = 433.0
|
||||
margin_bottom = 251.0
|
||||
margin_right = 276.0
|
||||
margin_bottom = 161.0
|
||||
rect_min_size = Vector2( 255, 150 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 7
|
||||
@ -35,16 +36,16 @@ icon_align = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="HBox"]
|
||||
margin_left = 437.0
|
||||
margin_right = 467.0
|
||||
margin_bottom = 251.0
|
||||
margin_left = 280.0
|
||||
margin_right = 310.0
|
||||
margin_bottom = 161.0
|
||||
theme = ExtResource( 4 )
|
||||
custom_constants/separation = 30
|
||||
|
||||
[node name="RegM_Btn" type="Button" parent="HBox"]
|
||||
margin_left = 471.0
|
||||
margin_right = 904.0
|
||||
margin_bottom = 251.0
|
||||
margin_left = 314.0
|
||||
margin_right = 590.0
|
||||
margin_bottom = 161.0
|
||||
rect_min_size = Vector2( 255, 150 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
@ -52,3 +53,22 @@ theme = ExtResource( 4 )
|
||||
icon = ExtResource( 3 )
|
||||
icon_align = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="HBox"]
|
||||
margin_left = 594.0
|
||||
margin_right = 624.0
|
||||
margin_bottom = 161.0
|
||||
theme = ExtResource( 4 )
|
||||
custom_constants/separation = 30
|
||||
|
||||
[node name="EoI_Btn" type="Button" parent="HBox"]
|
||||
margin_left = 628.0
|
||||
margin_right = 904.0
|
||||
margin_bottom = 161.0
|
||||
rect_min_size = Vector2( 255, 150 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 7
|
||||
theme = ExtResource( 4 )
|
||||
icon = ExtResource( 5 )
|
||||
icon_align = 1
|
||||
expand_icon = true
|
||||
|
@ -3,9 +3,11 @@ extends Panel
|
||||
|
||||
onready var RDP_Viewer = load("res://RDP/RDP_Viewer.tscn")
|
||||
onready var RegM_Viewer = load("res://RegM/RegM_Viewer.tscn")
|
||||
onready var EoI_Viewer = load("res://EoI/EoI_Viewer.tscn")
|
||||
|
||||
onready var RDP_Btn = get_node("HBox/RDP_Btn")
|
||||
onready var RegM_Btn = get_node("HBox/RegM_Btn")
|
||||
onready var EoI_Btn = get_node("HBox/EoI_Btn")
|
||||
|
||||
|
||||
func rdp_pressed():
|
||||
@ -14,8 +16,13 @@ func rdp_pressed():
|
||||
func regM_pressed():
|
||||
add_child( RegM_Viewer.instance() )
|
||||
|
||||
func eoi_pressed():
|
||||
add_child( EoI_Viewer.instance() )
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
EoI_Btn.connect("pressed", self, "eoi_pressed")
|
||||
RDP_Btn.connect("pressed", self, "rdp_pressed")
|
||||
RegM_Btn.connect("pressed", self, "regM_pressed")
|
||||
|
||||
|
@ -10,17 +10,23 @@ config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Object",
|
||||
"class": "Eva",
|
||||
"language": "GDScript",
|
||||
"path": "res://EoI/Scripts/Eva.gd"
|
||||
}, {
|
||||
"base": "Object",
|
||||
"class": "Lexer",
|
||||
"language": "GDScript",
|
||||
"path": "res://RDP/Scripts/Lexer.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Eva": "",
|
||||
"Lexer": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Parser"
|
||||
config/name="LangStudies"
|
||||
run/main_scene="res://Scenes/Persistent.tscn"
|
||||
config/icon="res://Assets/Branding/RDP_Class_cover_small.png"
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 99a923ce9e604b22fbdb9df745fcb67c4d2c8d56
|
||||
Subproject commit 32ef964b0f7d4e18a919e904988727b3ed775901
|
Loading…
x
Reference in New Issue
Block a user