Короткие программы вида

##
Print(1)

Преддверие литеральных массивов в виде |1,2,3| - пока без форматирования

Rot Triangle 1.vertex.glsl
This commit is contained in:
Mikhalkovich Stanislav 2020-07-04 22:49:42 +03:00
parent b5e5534ac8
commit 2794392e83
22 changed files with 4935 additions and 4570 deletions

View file

@ -5575,17 +5575,39 @@ namespace CodeCompletion
public override void visit(diapason_expr_new _diapason_expr_new)
{
/*_diapason_expr_new.left.visit(this);
TypeScope ts = TypeTable.get_compiled_type(new SymInfo("IEnumerable`1", SymbolKind.Type, "System.Collections.Generic.IEnumerable`1"), typeof(IEnumerable<>));
TypeScope elem_ts = returned_scope as TypeScope;
if (elem_ts != null)
ts = ts.GetInstance(new List<TypeScope>() { elem_ts });
returned_scope = ts;*/
method_call mc = new method_call();
mc.parameters = new expression_list(new List<expression> { _diapason_expr_new.left, _diapason_expr_new.right });
mc.dereferencing_value = new dot_node(new ident("PABCSystem"), new ident("InternalRange"));
mc.visit(this);
}
public override void visit(array_const_new acn)
{
TypeScope element_type = null;
List<TypeScope> element_types = new List<TypeScope>();
foreach (expression ex in acn.elements.expressions)
{
ex.visit(this);
if (returned_scope != null && returned_scope is TypeScope)
element_types.Add(returned_scope as TypeScope);
}
element_type = element_types[0];
for (int i = 1; i < element_types.Count; i++)
{
if (element_type.IsConvertable(element_types[i], true))
element_type = element_types[i];
else if (!element_types[i].IsConvertable(element_type, true))
{
element_type = TypeTable.obj_type;
break;
}
}
returned_scope = new ArrayScope(element_type,null);
cnst_val.prim_val = null;
}
}
}

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "6";
public const string Build = "3";
public const string Revision = "2548";
public const string Revision = "2551";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=3
%REVISION%=2548
%MINOR%=6
%REVISION%=2551
%COREVERSION%=3
%MAJOR%=3

View file

@ -0,0 +1,18 @@
#version 460
attribute vec2 position;
attribute vec3 color;
uniform float rot_k;
void main()
{
gl_Position.x = position.x*rot_k;
gl_Position.y = position.y;
gl_Position.z = 0.0f;
gl_Position.w = 1.0f;
gl_FrontColor.rgb = color;
gl_FrontColor.a = 1.0f;
}

File diff suppressed because it is too large Load diff

View file

@ -180,6 +180,8 @@ UNICODEARROW \x890
<COMMENT1>.|\n {
}
"|" { return (int)Tokens.tkVertParen; }
"##" { return (int)Tokens.tkShortProgram; }
"&" { return (int)Tokens.tkAmpersend; }
"," { yylval = new Union(); yylval.ti = new token_info(yytext); return (int)Tokens.tkComma; }
":" { return (int)Tokens.tkColon; }

View file

@ -39,7 +39,7 @@
%token <ti> tkLoop
%token <ti> tkSequence tkYield
%token <id> tkNew
%token <id> tkOn
%token <id> tkOn tkShortProgram tkVertParen
%token <id> tkName tkPrivate tkProtected tkPublic tkInternal tkRead tkWrite
%token <ti> tkParseModeExpression tkParseModeStatement tkParseModeType tkBegin tkEnd
%token <ti> tkAsmBody tkILCode tkError INVISIBLE
@ -51,7 +51,7 @@
%token <stn> tkStringLiteral tkFormatStringLiteral tkAsciiChar
%token <id> tkAbstract tkForward tkOverload tkReintroduce tkOverride tkVirtual tkExtensionMethod
%token <ex> tkInteger tkFloat tkHex
%token <id> tkUnknown
%token <id> tkUnknown
%type <ti> unit_key_word class_or_static
%type <stn> assignment
@ -188,8 +188,8 @@ parse_goal
{ root = $1; }
| parts
{ root = $1; }
// | stmt_list
// { root = $$ = NewProgramModule(null, null, null, null, new block(null, $1 as statement_list, @$), @$); }
| tkShortProgram stmt_list
{ root = $$ = NewProgramModule(null, null, null, new block(null, $2 as statement_list, @$), new token_info("end"), @$); }
;
parts
@ -888,6 +888,10 @@ const_set
{
$$ = new pascal_set_constant($2 as expression_list, @$);
}
| tkVertParen elem_list tkVertParen
{
$$ = new array_const_new($2 as expression_list, @$);
}
;
sign
@ -3916,6 +3920,10 @@ factor
{
$$ = new pascal_set_constant($2 as expression_list, @$);
}
| tkVertParen elem_list tkVertParen
{
$$ = new array_const_new($2 as expression_list, @$);
}
| tkNot factor
{
$$ = new un_expr($2, $1.type, @$);

File diff suppressed because it is too large Load diff

View file

@ -267,6 +267,8 @@ script=

View file

@ -1 +1 @@
3.6.3.2548
3.6.3.2551

View file

@ -1 +1 @@
!define VERSION '3.6.3.2548'
!define VERSION '3.6.3.2551'

View file

@ -1272,6 +1272,11 @@ namespace PascalABCCompiler.SyntaxTree
{
DefaultVisit(_index);
}
public virtual void visit(array_const_new _array_const_new)
{
DefaultVisit(_array_const_new);
}
}

View file

@ -2029,6 +2029,14 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void pre_do_visit(array_const_new _array_const_new)
{
}
public virtual void post_do_visit(array_const_new _array_const_new)
{
}
public override void visit(expression _expression)
{
DefaultVisit(_expression);
@ -4190,6 +4198,14 @@ namespace PascalABCCompiler.SyntaxTree
visit(index.index_expr);
post_do_visit(_index);
}
public override void visit(array_const_new _array_const_new)
{
DefaultVisit(_array_const_new);
pre_do_visit(_array_const_new);
visit(array_const_new.elements);
post_do_visit(_array_const_new);
}
}

View file

@ -526,6 +526,8 @@ namespace PascalABCCompiler.SyntaxTree
return new simple_expr_with_deref();
case 252:
return new index();
case 253:
return new array_const_new();
}
return null;
}
@ -4416,6 +4418,18 @@ namespace PascalABCCompiler.SyntaxTree
_index.inverted = br.ReadBoolean();
}
public void visit(array_const_new _array_const_new)
{
read_array_const_new(_array_const_new);
}
public void read_array_const_new(array_const_new _array_const_new)
{
read_expression(_array_const_new);
_array_const_new.elements = _read_node() as expression_list;
}
}

View file

@ -6908,6 +6908,27 @@ namespace PascalABCCompiler.SyntaxTree
bw.Write(_index.inverted);
}
public void visit(array_const_new _array_const_new)
{
bw.Write((Int16)253);
write_array_const_new(_array_const_new);
}
public void write_array_const_new(array_const_new _array_const_new)
{
write_expression(_array_const_new);
if (_array_const_new.elements == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_array_const_new.elements.visit(this);
}
}
}

View file

@ -54033,6 +54033,163 @@ namespace PascalABCCompiler.SyntaxTree
}
///<summary>
///
///</summary>
[Serializable]
public partial class array_const_new : expression
{
///<summary>
///Конструктор без параметров.
///</summary>
public array_const_new()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public array_const_new(expression_list _elements)
{
this._elements=_elements;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public array_const_new(expression_list _elements,SourceContext sc)
{
this._elements=_elements;
source_context = sc;
FillParentsInDirectChilds();
}
protected expression_list _elements;
///<summary>
///
///</summary>
public expression_list elements
{
get
{
return _elements;
}
set
{
_elements=value;
if (_elements != null)
_elements.Parent = this;
}
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
array_const_new copy = new array_const_new();
copy.Parent = this.Parent;
if (source_context != null)
copy.source_context = new SourceContext(source_context);
if (attributes != null)
{
copy.attributes = (attribute_list)attributes.Clone();
copy.attributes.Parent = copy;
}
if (elements != null)
{
copy.elements = (expression_list)elements.Clone();
copy.elements.Parent = copy;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new array_const_new TypedClone()
{
return Clone() as array_const_new;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
if (elements != null)
elements.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
elements?.FillParentsInAllChilds();
}
///<summary>
///Свойство для получения количества всех подузлов без элементов поля типа List
///</summary>
public override Int32 subnodes_without_list_elements_count
{
get
{
return 1;
}
}
///<summary>
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
///</summary>
public override Int32 subnodes_count
{
get
{
return 1;
}
}
///<summary>
///Индексатор для получения всех подузлов
///</summary>
public override syntax_tree_node this[Int32 ind]
{
get
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
return elements;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
elements = (expression_list)value;
break;
}
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
}

View file

@ -1522,6 +1522,12 @@ namespace PascalABCCompiler.SyntaxTree
///<param name="_index">Node to visit</param>
///<returns> Return value is void </returns>
void visit(index _index);
///<summary>
///Method to visit array_const_new.
///</summary>
///<param name="_array_const_new">Node to visit</param>
///<returns> Return value is void </returns>
void visit(array_const_new _array_const_new);
}

View file

@ -3270,6 +3270,16 @@
<TagIndices />
</Tags>
</SyntaxNode>
<SyntaxNode Name="array_const_new" BaseName="expression">
<Fields>
<SyntaxField Name="elements" SyntaxType="expression_list" />
</Fields>
<Methods />
<Tags>
<CategoryIndices />
<TagIndices />
</Tags>
</SyntaxNode>
</SyntaxNodes>
<Settings>
<FileName>Tree.cs</FileName>
@ -3326,6 +3336,7 @@
<HelpData Key=".defs" Value="" />
<HelpData Key=".directives" Value="" />
<HelpData Key=".el" Value="" />
<HelpData Key=".elements" Value="" />
<HelpData Key=".elements_type" Value="Тип элементов" />
<HelpData Key=".ex" Value="" />
<HelpData Key=".expr" Value="" />
@ -3401,6 +3412,8 @@
<HelpData Key="addressed_value_list.void Add(addressed_value av)" Value="" />
<HelpData Key="array_const" Value="" />
<HelpData Key="array_const.elements" Value="" />
<HelpData Key="array_const_new" Value="" />
<HelpData Key="array_const_new.elements" Value="" />
<HelpData Key="array_of_const_type" Value="array of const" />
<HelpData Key="array_of_const_type_defenition" Value="array of const" />
<HelpData Key="array_of_const_type_definition" Value="array of const" />

View file

@ -2063,6 +2063,10 @@ procedure Swap<T>(var a, b: T);
function Eoln: boolean;
/// Возвращает True, если достигнут конец потока ввода
function Eof: boolean;
/// Пропускает пробельные символы, после чего возвращает True, если достигнут конец потока ввода
function SeekEof: boolean;
/// Пропускает пробельные символы, после чего возвращает True, если достигнут конец строки
function SeekEoln: boolean;
/// Возвращает аргумены командой строки, с которыми была запущена программа
function CommandLineArgs: array of string;
@ -6624,7 +6628,9 @@ function Eoln: boolean;
begin
if not console_alloc then
AllocConsole;
Result := CurrentIOSystem.peek = 13
var next := CurrentIOSystem.peek;
Result := (next = -1) or (next = 13) or (next = 10);
//Result := CurrentIOSystem.peek = 13
end;
function Eof: boolean;
@ -6634,6 +6640,34 @@ begin
Result := CurrentIOSystem.peek = -1
end;
function SeekEof: boolean;
begin
repeat
if Eof then
break;
var i := CurrentIOSystem.peek;
if not char.IsWhiteSpace(char(i)) then
break;
CurrentIOSystem.read_symbol
until False;
Result := Eof;
end;
function SeekEoln: boolean;
begin
repeat
if Eoln then
break;
var i := CurrentIOSystem.peek;
if (i <> 32) and (i <> 9) then // Если это не пробел и не табуляция
break;
CurrentIOSystem.read_symbol;
until False;
var next := CurrentIOSystem.peek;
Result := (next = -1) or (next = 13) or (next = 10);
end;
// -----------------------------------------------------
// CommandLineArgs # CommandLineArgs subroutine
// -----------------------------------------------------

View file

@ -2694,7 +2694,8 @@ namespace PascalABCCompiler.TreeConverter
{
if (types[i] == ret_type) continue;
type_compare tc = type_table.compare_types_in_specific_order(types[i], ret_type, only_implicit);
if (tc == type_compare.greater_type && ret_type != SystemLibrary.SystemLibrary.object_type) ret_type = types[i];
if (tc == type_compare.greater_type && ret_type != SystemLibrary.SystemLibrary.object_type)
ret_type = types[i];
else if (tc == type_compare.non_comparable_type)
{
ret_type = SystemLibrary.SystemLibrary.object_type;

View file

@ -4994,6 +4994,20 @@ namespace PascalABCCompiler.TreeConverter
//return_value(new common_namespace_function_call_as_constant(cnfc,cnfc.location));
}
public override void visit(SyntaxTree.array_const_new acn)
{
var lst = acn.elements.expressions.Select(ex => convert_strong(ex)).ToList();
type_node_list types = new type_node_list();
foreach (var tn in lst.Select(ex => ex.type))
types.AddElement(tn);
var el_type = convertion_data_and_alghoritms.select_base_type(types, true);
var syntax_type = new SyntaxTree.semantic_type_node(el_type);
var plist = new SyntaxTree.expression_list(new int32_const(acn.elements.Count));
var nn = new SyntaxTree.new_expr(syntax_type, plist, true, new SyntaxTree.array_const(acn.elements, acn.elements.source_context), acn.source_context);
visit(nn);
}
internal List<SymbolInfo> get_function_instances(List<SymbolInfo> sil, List<SyntaxTree.type_definition> type_pars, string name, location loc, bool stop_on_error)
{
List<type_node> tparams = visit_type_list(type_pars);

View file

@ -31,7 +31,7 @@ DESTRUCTOR_NOT_IN_CLASS=Деструктор может быть описан т
ASSIGN_TO_EVENT=Оператор := не применим к событиям; используйте += и -=
DESTRUCTOR_IN_INTERFACE=Деструкторы не могут присутствовать в интерфейсе
CAN_NOT_CALL_CONSTRUCTOR_AS_PROCEDURE=Нельзя вызвать конструктор через объект
CANNOT_USE_POINTER_AS_GENERIC_ARGUMENT=Тип-указатель не может выступать в качестве параметра управляемого шаблона
CANNOT_USE_POINTER_AS_GENERIC_ARGUMENT=Тип-указатель не может выступать в качестве параметра обобщения
PARAMETER_{0}_MUST_HAVE_DEFAULT_CONSTRUCTOR=Невозможно инстанцировать, так как у типа {0} нет конструктора без параметров с уровнем доступа public
PARAMETER_{0}_MUST_BE_REFERENCE_TYPE=Невозможно инстанцировать, так как тип {0} не является ссылочным (классом)
PARAMETER_{0}_MUST_BE_VALUE_TYPE=Невозможно инстанцировать, так как тип {0} не является размерным