Conflicts:
	ReleaseGenerators/PascalABCNET_version.nsh
This commit is contained in:
miks1965 2016-04-03 22:07:37 +03:00
commit c13a976a2b
38 changed files with 80 additions and 5376 deletions

View file

@ -1383,6 +1383,7 @@ namespace CodeCompletion
if (_function_header.return_type != null)
_function_header.return_type.visit(this);
return_type = returned_scope as TypeScope;
cur_scope = tmp;
}
}

View file

@ -1844,6 +1844,7 @@ namespace CodeCompletion
int i = 0;
foreach (ElementScope parameter in this.parameters)
{
i++;
if (parameter.sc is UnknownScope || (parameter.sc is TypeScope) && (parameter.sc as TypeScope).IsGenericParameter)
{
int ind = this.template_parameters.IndexOf((parameter.sc as TypeScope).Name);
@ -1863,6 +1864,8 @@ namespace CodeCompletion
inst_param = new ElementScope(parameter.si, parameter.sc, parameter.topScope);
instance.parameters.Add(inst_param);
}
if (parameter.param_kind == parametr_kind.params_parametr && i < gen_args.Count)
gen_args.RemoveRange(i, gen_args.Count - i);
}
instance.si = this.si;
instance.return_type = this.return_type.GetInstance(gen_args);
@ -2517,6 +2520,13 @@ namespace CodeCompletion
si.describe = name + " in " + declScope.si.name;
}
public override TypeScope GetInstance(List<TypeScope> gen_args)
{
if (gen_args.Count > 0)
return gen_args[0];
return this;
}
public override bool IsGenericParameter
{
get
@ -3855,6 +3865,8 @@ namespace CodeCompletion
if (this is UnknownScope && ts is CompiledScope && (ts as CompiledScope).CompiledType.IsGenericParameter
|| ts is UnknownScope && this is CompiledScope && (this as CompiledScope).CompiledType.IsGenericParameter)
return true;
if (this.IsGenericParameter && ts.IsGenericParameter && this.Name == ts.Name)
return true;
TypeScope tmp = this.baseScope;
while (tmp != null)
if (tmp.IsEqual(ts))
@ -4767,10 +4779,19 @@ namespace CodeCompletion
{
Type t = this.ctn;
if (!ctn.IsGenericTypeDefinition)
t = PascalABCCompiler.NetHelper.NetHelper.FindType(this.ctn.Namespace+"."+this.ctn.Name);
t = PascalABCCompiler.NetHelper.NetHelper.FindType(this.ctn.Namespace + "." + this.ctn.Name);
else if (this.instances != null && this.instances.Count > 0)
{
if (this.instances.Count != ctn.GetGenericArguments().Length)
{
Type t2 = PascalABCCompiler.NetHelper.NetHelper.FindType(this.ctn.Namespace + "." + this.ctn.Name.Substring(0, this.ctn.Name.IndexOf('`')) + "`" + this.instances.Count);
if (t2 != null)
t = t2;
}
}
else if (gen_args.Count != ctn.GetGenericArguments().Length)
{
Type t2 = PascalABCCompiler.NetHelper.NetHelper.FindType(this.ctn.Namespace+"."+this.ctn.Name.Substring(0, this.ctn.Name.IndexOf('`')) + "`" + gen_args.Count);
{
Type t2 = PascalABCCompiler.NetHelper.NetHelper.FindType(this.ctn.Namespace + "." + this.ctn.Name.Substring(0, this.ctn.Name.IndexOf('`')) + "`" + gen_args.Count);
if (t2 != null)
t = t2;
}
@ -4778,11 +4799,24 @@ namespace CodeCompletion
sc.generic_params = new List<string>();
sc.instances = new List<TypeScope>();
sc.original_type = this;
for (int i = 0; i < gen_args.Count; i++)
{
sc.generic_params.Add(gen_args[i].si.name);
sc.instances.Add(gen_args[i]);
}
if (this.instances != null && this.instances.Count > 0)
for (int i = 0; i < this.instances.Count; i++)
{
if (this.instances[i] is UnknownScope || this.instances[i] is TemplateParameterScope)
{
List<TypeScope> lst = new List<TypeScope>();
lst.Add(gen_args[Math.Min(i, gen_args.Count - 1)]);
sc.instances.Add(this.instances[i].GetInstance(lst));
}
else
sc.instances.Add(this.instances[i].GetInstance(gen_args));
}
else
for (int i = 0; i < gen_args.Count; i++)
{
sc.generic_params.Add(gen_args[i].si.name);
sc.instances.Add(gen_args[i]);
}
sc.si.describe = sc.GetDescription();
return sc;
}
@ -6275,7 +6309,7 @@ namespace CodeCompletion
generic_args = new List<string>();
generic_args.AddRange(args);
}
if (generic_args != null)
if (generic_args != null || declaringType.instances != null )
{
//TypeScope ts = declaringType.instances[pi.PropertyType.GenericParameterPosition];
this.sc = CompiledScope.get_type_instance(pi.PropertyType, declaringType.instances);
@ -6911,6 +6945,8 @@ namespace CodeCompletion
public override TypeScope GetInstance(List<TypeScope> gen_args)
{
if (gen_args.Count > 0)
return gen_args[0];
return this;
}

View file

@ -2260,7 +2260,11 @@ namespace PascalABCCompiler.NETGenerator
if (parameters[i].is_params)
pb.SetCustomAttribute(TypeFactory.ParamArrayAttributeConstructor, new byte[] { 0x1, 0x0, 0x0, 0x0 });
if (default_value != null)
{
if (default_value.GetType() != param_types[i + num] && param_types[i + num].IsEnum && (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX))
default_value = Enum.ToObject(param_types[i + num], default_value);
pb.SetConstant(default_value);
}
if (func.functions_nodes.Length > 0)
{
FieldBuilder fb = null;

View file

@ -70,20 +70,6 @@
<Compile Include="ParserTools\CommentBinder.cs" />
<Compile Include="ParserTools\DefaultLanguageInformation.cs" />
<Compile Include="ParserTools\Errors.cs" />
<Compile Include="ParserTools\GoldParser\DfaState.cs" />
<Compile Include="ParserTools\GoldParser\Grammar.cs" />
<Compile Include="ParserTools\GoldParser\LRAction.cs" />
<Compile Include="ParserTools\GoldParser\LRState.cs" />
<Compile Include="ParserTools\GoldParser\LRStateAction.cs" />
<Compile Include="ParserTools\GoldParser\ObjectMap.cs" />
<Compile Include="ParserTools\GoldParser\ParseMessage.cs" />
<Compile Include="ParserTools\GoldParser\Parser.cs" />
<Compile Include="ParserTools\GoldParser\Rule.cs" />
<Compile Include="ParserTools\GoldParser\SourceLineReadCallback.cs" />
<Compile Include="ParserTools\GoldParser\SR.cs" />
<Compile Include="ParserTools\GoldParser\Symbol.cs" />
<Compile Include="ParserTools\GoldParser\SymbolType.cs" />
<Compile Include="ParserTools\GPBParserTools.cs" />
<Compile Include="ParserTools\IPreprocessor.cs" />
<Compile Include="ParserTools\Keyword.cs" />
<Compile Include="ParserTools\LanguageInformation.cs" />

View file

@ -46,16 +46,6 @@ namespace PascalABCCompiler.Errors
{
}
}
public class TokenReadError : SyntaxError
{
public TokenReadError(PascalABCCompiler.ParserTools.GPBParser parser)
: base(string.Format(ParserErrorsStringResources.Get("UNEXPECTED_SYMBOL{0}"), parser.LRParser.TokenText!="" ? parser.LRParser.TokenText : "(EOF)"),
parser.current_file_name,
parser.parsertools.GetTokenSourceContext(parser.LRParser),
(syntax_tree_node)parser.prev_node)
{
}
}
public class BadExpr : SyntaxError
{
public BadExpr(string _file_name, SourceContext _source_context, syntax_tree_node _node)
@ -63,17 +53,6 @@ namespace PascalABCCompiler.Errors
{
}
}
public class UnexpectedToken : SyntaxError
{
public UnexpectedToken(PascalABCCompiler.ParserTools.GPBParser parser,string ExpectedTokens)
: base(string.Format(ParserErrorsStringResources.Get("EXPECTED{0}"), ExpectedTokens),
parser.current_file_name, parser.parsertools.GetTokenSourceContext(parser.LRParser), (syntax_tree_node)parser.prev_node)
{
}
}
public class TooBigCharNumberInSharpCharConstant: SyntaxError
{
public TooBigCharNumberInSharpCharConstant(string _file_name, SourceContext _source_context, syntax_tree_node _node)

View file

@ -1,433 +0,0 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Text;
using System.Collections.Generic;
//using com.calitha.goldparser;
using System.Runtime.Serialization;
using PascalABCCompiler.SyntaxTree;
using PascalABCCompiler.Errors;
using System.IO;
using GoldParser;
namespace PascalABCCompiler.ParserTools
{
public class GPBParser // Странный класс, не являющийся парсером, а служащий для передачи информации. Состоит из двух частей: ссылок на парсер и грамматику и информации для передачи
{
public Parser LRParser;
public Grammar LanguageGrammar;
public List<Error> errors;
public string current_file_name;
public int max_errors = 10;
public object prev_node = null;
public parser_tools parsertools;
public List<compiler_directive> CompilerDirectives;
public GPBParser(Stream stream)
{
LRParser = null;
LanguageGrammar = new GoldParser.Grammar(new BinaryReader(stream));
}
public GPBParser(GoldParser.Grammar grammar)
{
LRParser = null;
LanguageGrammar = grammar;
}
public GPBParser()
{
LRParser = null;
LanguageGrammar = null;
}
}
[Serializable()]
public class SymbolException : System.Exception
{
public SymbolException(string message) : base(message)
{
}
public SymbolException(string message,
Exception inner) : base(message, inner)
{
}
protected SymbolException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
}
[Serializable()]
public class RuleException : System.Exception
{
public RuleException(string message) : base(message)
{
}
public RuleException(string message,
Exception inner) : base(message, inner)
{
}
protected RuleException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
}
public class parser_tools
{
private const int max_char_const=0xFFFF;
public int LineCorrection = 0;
public GoldParser.Parser parser; // Ужас - два разных парсера! SSM 19.01.12
public virtual void check_comment_text(GPBParser parser)
{
}
public virtual SourceContext GetTokenSourceContext()
{
int LineNum = parser.TokenLineNumber + LineCorrection;
return new SourceContext(LineNum, parser.TokenLinePosition, LineNum, parser.TokenLinePosition + parser.TokenLength - 1, parser.TokenCharPosition, parser.TokenCharPosition + parser.TokenLength);
}
public virtual SourceContext GetTokenSourceContext(GoldParser.Parser parser)
{
int LineNum = parser.TokenLineNumber + LineCorrection;
return new SourceContext(LineNum, parser.TokenLinePosition, LineNum, parser.TokenLinePosition + parser.TokenLength - 1, parser.TokenCharPosition, parser.TokenCharPosition + parser.TokenLength);
}
/*public virtual string terminal_token_to_string(TerminalToken token)
{
string name=symbol_to_string(token.Symbol);
if (name!=null) return name;
if (token.UserObject!=null)
{
if (token.UserObject is token_info) return ((token_info)token.UserObject).text;
return token.UserObject.ToString();
}
return token.Text;
} */
public virtual List<Symbol> GetPrioritySymbols(Symbol[] Symbols)
{
List<Symbol> res = new List<Symbol>();
int maxp = -1, p;
foreach (Symbol symbol in Symbols)
{
p = symbol_priority(symbol);
if (p > maxp) maxp = p;
}
foreach (Symbol symbol in Symbols)
if (symbol_priority(symbol) == maxp)
res.Add(symbol);
return res;
}
public string[] SymbolsToStrings(Symbol[] Symbols)
{
string[] res = new string[Symbols.Length>0?1:0];
for (int i = 0; i < res.Length; i++)
res[i] = symbol_to_string(Symbols[i]);
return res;
}
public virtual string symbol_collection_to_string(Symbol[] Symbols)
{
return PascalABCCompiler.FormatTools.ObjectsToString(SymbolsToStrings(GetPrioritySymbols(Symbols).ToArray()), ",");
}
public virtual string symbol_to_string(Symbol symbol)
{
return null;
}
public virtual int symbol_priority(Symbol symbol)
{
return 0;
}
public virtual ident create_directive_name(GPBParser parser)
{
return create_directive_name(parser.LRParser.TokenString, GetTokenSourceContext(parser.LRParser));
}
public virtual ident create_directive_name(string text, SourceContext sc)
{
ident dn = new ident(new string(text.ToCharArray(1, text.Length - 1)));
dn.source_context = sc;
return dn;
}
public virtual string ReplaceSpecialSymbols(string text)
{
text = text.Replace("''", "'");
return text;
}
public virtual char_const create_char_const(GPBParser parser)
{
return create_char_const(parser.LRParser.TokenString,GetTokenSourceContext(parser.LRParser));
}
public char_const create_char_const(string text, SourceContext sc)
{
string char_text = new string(text.ToCharArray(1, text.Length - 2));
char_text = ReplaceSpecialSymbols(char_text);
char_const ct = new char_const();
ct.source_context = sc;
if (char_text.Length == 1)
{
ct.cconst = char_text[0];
return ct;
}
return null;
}
public virtual sharp_char_const create_sharp_char_const(GPBParser parser)
{
string text = parser.LRParser.TokenString;
string int_text = new string(text.ToCharArray(1, text.Length - 1));
SourceContext sc = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
sharp_char_const scc = null;
int val = 0;
if (int.TryParse(int_text, out val))
{
if (val > max_char_const)
{
scc = new sharp_char_const(0);
parser.errors.Add(new TooBigCharNumberInSharpCharConstant(parser.current_file_name, sc, scc));
}
else
scc = new sharp_char_const(val);
scc.source_context = sc;
}
else
{
parser.errors.Add(new TooBigCharNumberInSharpCharConstant(parser.current_file_name, sc, scc));
}
return scc;
}
public virtual const_node create_double_const(GPBParser parser)
{
const_node cn=null;
SourceContext sc = GetTokenSourceContext(parser.LRParser);
try
{
System.Globalization.NumberFormatInfo sgnfi=new System.Globalization.NumberFormatInfo();
sgnfi.NumberDecimalSeparator=".";
double val=double.Parse(parser.LRParser.TokenString,sgnfi);
cn=new double_const(val);
cn.source_context=sc;
}
catch(Exception)
{
parser.errors.Add(new BadFloat(parser.current_file_name,sc,(syntax_tree_node)parser.prev_node));
}
return cn;
}
public virtual const_node create_int_const(GPBParser parser)
{
return create_int_const(parser, System.Globalization.NumberStyles.Integer);
}
public virtual const_node create_hex_const(GPBParser parser)
{
return create_int_const(parser, System.Globalization.NumberStyles.HexNumber);
}
public virtual const_node create_int_const(GPBParser parser, System.Globalization.NumberStyles NumberStyles)
{
//таблица целых констант на уровне синтаксиса
// не может быть - 0 +
// 32--------16----8----|----8----16--------32----------------64(bits)
// [ int64 )[ int32 ]( int64 ]( uint64 ]
string text = parser.LRParser.TokenString;
if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
text = text.Substring(1);
const_node cn=new int32_const();
SourceContext sc = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
if (text.Length < 8)
(cn as int32_const).val = Int32.Parse(text, NumberStyles);
else
{
try
{
UInt64 uint64 = UInt64.Parse(text, NumberStyles);
if (uint64 <= Int32.MaxValue)
(cn as int32_const).val = (Int32)uint64;
else
if (uint64 <= Int64.MaxValue)
cn = new int64_const((Int64)uint64);
else
cn = new uint64_const(uint64);
}
catch (Exception)
{
if(NumberStyles == System.Globalization.NumberStyles.HexNumber)
parser.errors.Add(new BadHex(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
else
parser.errors.Add(new BadInt(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
}
}
cn.source_context = sc;
return cn;
}
public virtual ident create_ident(GPBParser parser)
{
string text = parser.LRParser.TokenString;
if (text.IndexOf('&') == 0)
text = text.Substring(1);
ident id = new ident(text);
id.source_context = GetTokenSourceContext(parser.LRParser);
return id;
}
public procedure_attributes_list AddModifier(procedure_attributes_list proc_list, SyntaxTree.proc_attribute modif)
{
if (proc_list == null)
proc_list = new procedure_attributes_list();
foreach (procedure_attribute attr in proc_list.proc_attributes)
if (attr.attribute_type == modif)
return proc_list;
proc_list.proc_attributes.Add(new procedure_attribute(modif));
return proc_list;
}
public virtual literal create_string_const(GPBParser parser)
{
literal lt;
string text = parser.LRParser.TokenString;
if (text.Length==3 && text[0]=='\'' && text[2]=='\'')
{
lt=new char_const(text[1]);
lt.source_context = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
return lt;
}
text = ReplaceSpecialSymbols(text.Substring(1, text.Length - 2));
lt=new string_const(text);
lt.source_context = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
return lt;
}
/*public SourceContext create_source_context(com.calitha.goldparser.TerminalToken token)
{
return new SourceContext(token.Location.LineNr+1,token.Location.ColumnNr+1,token.Location.LineNr+1,token.Location.ColumnNr+token.Text.Length);
}
public file_position create_file_position(com.calitha.goldparser.TerminalToken token)
{
return new file_position(token.Location.LineNr+1,token.Location.ColumnNr+1);
}*/
public void create_source_context(object to,object left,object right)
{
if (to != null)
((syntax_tree_node)to).source_context = get_source_context(left, right);
}
public SourceContext get_source_context(object left, object right)
{
//debug
/*if (left == null && right!=null)
{
Console.WriteLine("\n\rerror: left is null(create_source_context)!\n\r");
Console.WriteLine(((syntax_tree_node)right).source_context.ToString());
}
if (right == null && left!=null)
{
Console.WriteLine("\n\rerror: right is null(create_source_context)!\n\r");
Console.WriteLine(((syntax_tree_node)left).source_context.ToString());
}
if (((syntax_tree_node)left).source_context == null)
{
Console.WriteLine("\n\rerror: source_context is null!(left)\n\r");
return null;
}
if (((syntax_tree_node)right).source_context == null)
{
Console.WriteLine("\n\rerror: source_context is null!(right)\n\r");
return null;
}
*/
if ((left == null) || (right == null) || (((syntax_tree_node)left).source_context == null) || (((syntax_tree_node)right).source_context == null))
return null;
return new SourceContext(((syntax_tree_node)left).source_context, ((syntax_tree_node)right).source_context);
}
public void create_source_context_left(object to, object left)
{
file_position fp=((syntax_tree_node)left).source_context.begin_position;
((syntax_tree_node)to).source_context = new SourceContext(fp.line_num,fp.column_num,fp.line_num,fp.column_num,0,0);
}
public void create_source_context_right(object to, object right)
{
file_position fp = ((syntax_tree_node)right).source_context.end_position;
((syntax_tree_node)to).source_context = new SourceContext(fp.line_num, fp.column_num, fp.line_num, fp.column_num, 0, 0);
}
public object sc_not_null(object o1, object o2)
{
if (o1 != null)
if (((syntax_tree_node)o1).source_context != null) return o1;
return o2;
}
public object sc_not_null(object o1, object o2,object o3)
{
if (o1 != null)
if (((syntax_tree_node)o1).source_context != null) return o1;
if (o2 != null)
if (((syntax_tree_node)o2).source_context != null) return o2;
return o3;
}
public object sc_not_null(params object[] arr)
{
foreach(object o in arr)
if (o!=null)
if (((syntax_tree_node)o).source_context!=null) return o;
return null;
}
public void assign_source_context(object to,object from)
{
//debug
//if (((tree_node)from).source_context==null) Console.WriteLine("\n\rerror: from sc is null(assign_source_context)!\n\r");
((syntax_tree_node)to).source_context=((syntax_tree_node)from).source_context;
}
/*public SourceContext create_source_context(Token[] tokens)
{
object right=null,left=null;
for(int i=0;i<tokens.Length;i++)
if (tokens[i].UserObject!=null)
if(((tree_node)tokens[i].UserObject).source_context!=null)
{
if (left==null)
left=tokens[i].UserObject;
right=tokens[i].UserObject;
}
if (left==null) return null;
return new SourceContext(((tree_node)left).source_context,((tree_node)right).source_context);
}*/
}
}

View file

@ -1,66 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
using System.Collections;
#endregion
namespace GoldParser
{
/// <summary>
/// State in the Deterministic Finite Automata
/// which is used by the tokenizer.
/// </summary>
public class DfaState
{
private int m_index;
internal Symbol m_acceptSymbol;
internal ObjectMap m_transitionVector;
/// <summary>
/// Creates a new instance of the <c>DfaState</c> class.
/// </summary>
/// <param name="index">Index in the DFA state table.</param>
/// <param name="acceptSymbol">Symbol to accept.</param>
/// <param name="transitionVector">Transition vector.</param>
public DfaState(int index, Symbol acceptSymbol, ObjectMap transitionVector)
{
m_index = index;
m_acceptSymbol = acceptSymbol;
m_transitionVector = transitionVector;
}
/// <summary>
/// Gets index of the state in DFA state table.
/// </summary>
public int Index
{
get { return m_index; }
}
/// <summary>
/// Gets the symbol which can be accepted in this DFA state.
/// </summary>
public Symbol AcceptSymbol
{
get { return m_acceptSymbol; }
}
}
}

View file

@ -1,624 +0,0 @@
//#define STRONG_CGT_CHECK
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
using System.IO;
using System.Text;
using System.Collections;
#endregion
namespace GoldParser
{
/// <summary>
/// Contains grammar tables required for parsing.
/// </summary>
public class Grammar
{
#region Fields and constants
/// <summary>
/// Identifies Gold parser grammar file.
/// </summary>
public const string FileHeader = "GOLD Parser Tables/v1.0";
// Grammar header information
private string m_name; // Name of the grammar
private string m_version; // Version of the grammar
private string m_author; // Author of the grammar
private string m_about; // Grammar description
private int m_startSymbolIndex; // Start symbol index
private bool m_caseSensitive; // Grammar is case sensitive or not
// Tables read from the binary grammar file
internal Symbol[] m_symbolTable; // Symbol table
private String[] m_charSetTable; // Charset table
internal Rule[] m_ruleTable; // Rule table
internal DfaState[] m_dfaStateTable; // DFA state table
internal LRState[] m_lrStateTable; // LR state table
// Initial states
internal int m_dfaInitialStateIndex; // DFA initial state index
internal DfaState m_dfaInitialState; // DFA initial state
internal int m_lrInitialState; // LR initial state
// Internal state of grammar parser
private BinaryReader m_reader; // Source of the grammar
private int m_entryCount; // Number of entries left
internal Symbol m_errorSymbol;
internal Symbol m_endSymbol;
#endregion
#region Constructors
/// <summary>
/// Creates a new instance of <c>Grammar</c> class
/// </summary>
/// <param name="reader"></param>
public Grammar(BinaryReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
m_reader = reader;
Load();
}
#endregion
#region Public members
/// <summary>
/// Gets grammar name.
/// </summary>
public string Name
{
get { return m_name; }
}
/// <summary>
/// Gets grammar version.
/// </summary>
public string Version
{
get { return m_version; }
}
/// <summary>
/// Gets grammar author.
/// </summary>
public string Author
{
get { return m_author; }
}
/// <summary>
/// Gets grammar description.
/// </summary>
public string About
{
get { return m_about; }
}
/// <summary>
/// Gets the start symbol for the grammar.
/// </summary>
public Symbol StartSymbol
{
get { return m_symbolTable[m_startSymbolIndex]; }
}
/// <summary>
/// Gets the value indicating if the grammar is case sensitive.
/// </summary>
public bool CaseSensitive
{
get { return m_caseSensitive; }
}
/// <summary>
/// Gets initial DFA state.
/// </summary>
public DfaState DfaInitialState
{
get { return m_dfaInitialState; }
}
/// <summary>
/// Gets initial LR state.
/// </summary>
public LRState InitialLRState
{
get { return m_lrStateTable[m_lrInitialState]; }
}
/// <summary>
/// Gets a special symbol to designate last token in the input stream.
/// </summary>
public Symbol EndSymbol
{
get { return m_endSymbol; }
}
#endregion
#region Private members
/// <summary>
/// Loads grammar from the binary reader.
/// </summary>
private void Load()
{
if (FileHeader != ReadString())
{
throw new FileLoadException(SR.GetString(SR.Grammar_WrongFileHeader));
}
while (m_reader.PeekChar() != -1)
{
RecordType recordType = ReadNextRecord();
switch (recordType)
{
case RecordType.Parameters:
ReadHeader();
break;
case RecordType.TableCounts:
ReadTableCounts();
break;
case RecordType.Initial:
ReadInitialStates();
break;
case RecordType.Symbols:
ReadSymbols();
break;
case RecordType.CharSets:
ReadCharSets();
break;
case RecordType.Rules:
ReadRules();
break;
case RecordType.DfaStates:
ReadDfaStates();
break;
case RecordType.LRStates:
ReadLRStates();
break;
default:
throw new FileLoadException(SR.GetString(SR.Grammar_InvalidRecordType));
}
}
m_dfaInitialState = m_dfaStateTable[m_dfaInitialStateIndex];
OptimizeDfaTransitionVectors();
}
/// <summary>
/// Reads the next record in the binary grammar file.
/// </summary>
/// <returns>Read record type.</returns>
private RecordType ReadNextRecord()
{
char recordType = (char) ReadByte();
//Structure below is ready for future expansion
switch (recordType)
{
case 'M':
//Read the number of entry's
m_entryCount = ReadInt16();
return (RecordType) ReadByteEntry();
default:
throw new FileLoadException(SR.GetString(SR.Grammar_InvalidRecordHeader));
}
}
/// <summary>
/// Reads grammar header information.
/// </summary>
private void ReadHeader()
{
m_name = ReadStringEntry();
m_version = ReadStringEntry();
m_author = ReadStringEntry();
m_about = ReadStringEntry();
m_caseSensitive = ReadBoolEntry();
m_startSymbolIndex = ReadInt16Entry();
}
/// <summary>
/// Reads table record counts and initializes tables.
/// </summary>
private void ReadTableCounts()
{
// Initialize tables
m_symbolTable = new Symbol [ReadInt16Entry()];
m_charSetTable = new String [ReadInt16Entry()];
m_ruleTable = new Rule [ReadInt16Entry()];
m_dfaStateTable = new DfaState [ReadInt16Entry()];
m_lrStateTable = new LRState [ReadInt16Entry()];
}
/// <summary>
/// Read initial DFA and LR states.
/// </summary>
private void ReadInitialStates()
{
m_dfaInitialStateIndex = ReadInt16Entry();
m_lrInitialState = ReadInt16Entry();
}
/// <summary>
/// Read symbol information.
/// </summary>
private void ReadSymbols()
{
int index = ReadInt16Entry();
string name = ReadStringEntry();
SymbolType symbolType = (SymbolType) ReadInt16Entry();
Symbol symbol = new Symbol(index, name, symbolType);
switch (symbolType)
{
case SymbolType.Error:
m_errorSymbol = symbol;
break;
case SymbolType.End:
m_endSymbol = symbol;
break;
}
m_symbolTable[index] = symbol;
}
/// <summary>
/// Read char set information.
/// </summary>
private void ReadCharSets()
{
m_charSetTable[ReadInt16Entry()] = ReadStringEntry();
}
/// <summary>
/// Read rule information.
/// </summary>
private void ReadRules()
{
int index = ReadInt16Entry();
Symbol nonTerminal = m_symbolTable[ReadInt16Entry()];
ReadEmptyEntry();
Symbol[] symbols = new Symbol[m_entryCount];
for (int i = 0 ; i < symbols.Length; i++)
{
symbols[i] = m_symbolTable[ReadInt16Entry()];
}
Rule rule = new Rule(index, nonTerminal, symbols);
m_ruleTable[index] = rule;
}
/// <summary>
/// Read DFA state information.
/// </summary>
private void ReadDfaStates()
{
int index = ReadInt16Entry();
Symbol acceptSymbol = null;
bool acceptState = ReadBoolEntry();
if (acceptState)
{
acceptSymbol = m_symbolTable[ReadInt16Entry()];
}
else
{
ReadInt16Entry(); // Skip the entry.
}
ReadEmptyEntry();
// Read DFA edges
DfaEdge[] edges = new DfaEdge[m_entryCount / 3];
for (int i = 0; i < edges.Length; i++)
{
edges[i].CharSetIndex = ReadInt16Entry();
edges[i].TargetIndex = ReadInt16Entry();
ReadEmptyEntry();
}
// Create DFA state and store it in DFA state table
ObjectMap transitionVector = CreateDfaTransitionVector(edges);
DfaState dfaState = new DfaState(index, acceptSymbol, transitionVector);
m_dfaStateTable[index] = dfaState;
}
/// <summary>
/// Read LR state information.
/// </summary>
private void ReadLRStates()
{
int index = ReadInt16Entry();
ReadEmptyEntry();
LRStateAction[] stateTable = new LRStateAction[m_entryCount / 4];
for (int i = 0; i < stateTable.Length; i++)
{
Symbol symbol = m_symbolTable[ReadInt16Entry()];
LRAction action = (LRAction) ReadInt16Entry();
int targetIndex = ReadInt16Entry();
ReadEmptyEntry();
stateTable[i] = new LRStateAction(i, symbol, action, targetIndex);
}
// Create the transition vector
LRStateAction[] transitionVector = new LRStateAction[m_symbolTable.Length];
for (int i = 0; i < transitionVector.Length; i++)
{
transitionVector[i] = null;
}
for (int i = 0; i < stateTable.Length; i++)
{
transitionVector[stateTable[i].Symbol.Index] = stateTable[i];
}
LRState lrState = new LRState(index, stateTable, transitionVector);
m_lrStateTable[index] = lrState;
}
/// <summary>
/// Creates the DFA state transition vector.
/// </summary>
/// <param name="edges">Array of automata edges.</param>
/// <returns>Hashtable with the transition information.</returns>
private ObjectMap CreateDfaTransitionVector(DfaEdge[] edges)
{
ObjectMap transitionVector = new ObjectMap();
for (int i = edges.Length; --i >= 0;)
{
string charSet = m_charSetTable[edges[i].CharSetIndex];
for (int j = 0; j < charSet.Length; j++)
{
transitionVector[charSet[j]] = edges[i].TargetIndex;
}
}
return transitionVector;
}
/// <summary>
/// Reads empty entry from the grammar file.
/// </summary>
private void ReadEmptyEntry()
{
#if STRONG_CGT_CHECK
if (ReadEntryType() != EntryType.Empty)
{
throw new FileLoadException(SR.GetString(SR.Grammar_EmptyEntryExpected));
}
#elif !STRONG_CGT_CHECK
m_reader.ReadByte();
#endif
m_entryCount--;
}
/// <summary>
/// Reads string entry from the grammar file.
/// </summary>
/// <returns>String entry content.</returns>
private string ReadStringEntry()
{
#if STRONG_CGT_CHECK
if (ReadEntryType() != EntryType.String)
{
throw new FileLoadException(SR.GetString(SR.Grammar_StringEntryExpected));
}
#elif !STRONG_CGT_CHECK
m_reader.ReadByte();
#endif
m_entryCount--;
return ReadString();
}
/// <summary>
/// Reads Int16 entry from the grammar file.
/// </summary>
/// <returns>Int16 entry content.</returns>
private int ReadInt16Entry()
{
#if STRONG_CGT_CHECK
if (ReadEntryType() != EntryType.Integer)
{
throw new FileLoadException(SR.GetString(SR.Grammar_IntegerEntryExpected));
}
#elif !STRONG_CGT_CHECK
m_reader.ReadByte();
#endif
m_entryCount--;
return ReadInt16();
}
/// <summary>
/// Reads byte entry from the grammar file.
/// </summary>
/// <returns>Byte entry content.</returns>
private byte ReadByteEntry()
{
#if STRONG_CGT_CHECK
if (ReadEntryType() != EntryType.Byte)
{
throw new FileLoadException(SR.GetString(SR.Grammar_ByteEntryExpected));
}
#elif !STRONG_CGT_CHECK
m_reader.ReadByte();
#endif
m_entryCount--;
return ReadByte();
}
/// <summary>
/// Reads boolean entry from the grammar file.
/// </summary>
/// <returns>Boolean entry content.</returns>
private bool ReadBoolEntry()
{
#if STRONG_CGT_CHECK
if (ReadEntryType() != EntryType.Boolean)
{
throw new FileLoadException(SR.GetString(SR.Grammar_BooleanEntryExpected));
}
#elif !STRONG_CGT_CHECK
m_reader.ReadByte();
#endif
m_entryCount--;
return ReadBool();
}
/// <summary>
/// Reads entry type.
/// </summary>
/// <returns>Entry type.</returns>
private EntryType ReadEntryType()
{
if (m_entryCount == 0)
{
throw new FileLoadException(SR.GetString(SR.Grammar_NoEntry));
}
return (EntryType) ReadByte();
}
/// <summary>
/// Reads string from the grammar file.
/// </summary>
/// <returns>String value.</returns>
private string ReadString()
{
StringBuilder result = new StringBuilder();
char unicodeChar = (char) ReadInt16();
while (unicodeChar != (char) 0)
{
result.Append(unicodeChar);
unicodeChar = (char) ReadInt16();
}
return result.ToString();
}
/// <summary>
/// Reads two byte integer Int16 from the grammar file.
/// </summary>
/// <returns>Int16 value.</returns>
private int ReadInt16()
{
return m_reader.ReadUInt16();
}
/// <summary>
/// Reads byte from the grammar file.
/// </summary>
/// <returns>Byte value.</returns>
private byte ReadByte()
{
return m_reader.ReadByte();
}
/// <summary>
/// Reads boolean from the grammar file.
/// </summary>
/// <returns>Boolean value.</returns>
private bool ReadBool()
{
return (ReadByte() == 1);
}
private void OptimizeDfaTransitionVectors()
{
DfaState[] dfaStates = m_dfaStateTable;
foreach (DfaState state in dfaStates)
{
ObjectMap transitions = state.m_transitionVector;
for (int i = transitions.Count; --i >= 0;)
{
int key = transitions.GetKey(i);
object transition = transitions[key];
if (transition != null)
{
int transitionIndex = (int) transition;
if (transitionIndex >= 0)
{
transitions[key] = dfaStates[transitionIndex];
}
else
{
transitions[key] = null;
}
}
}
transitions.ReadOnly = true;
}
}
#endregion
#region Private type definitions
/// <summary>
/// Record type byte in the binary grammar file.
/// </summary>
private enum RecordType
{
Parameters = (int) 'P', // 80
TableCounts = (int) 'T', // 84
Initial = (int) 'I', // 73
Symbols = (int) 'S', // 83
CharSets = (int) 'C', // 67
Rules = (int) 'R', // 82
DfaStates = (int) 'D', // 68
LRStates = (int) 'L', // 76
Comment = (int) '!' // 33
}
/// <summary>
/// Entry type byte in the binary grammar file.
/// </summary>
private enum EntryType
{
Empty = (int) 'E', // 69
Integer = (int) 'I', // 73
String = (int) 'S', // 83
Boolean = (int) 'B', // 66
Byte = (int) 'b' // 98
}
/// <summary>
/// Edge between DFA states.
/// </summary>
private struct DfaEdge
{
public int CharSetIndex;
public int TargetIndex;
}
#endregion
}
}

View file

@ -1,61 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// LR parser action type.
/// </summary>
public enum LRAction
{
/// <summary>
/// No action. Not used.
/// </summary>
None = 0,
/// <summary>
/// Shift a symbol and go to a state
/// </summary>
Shift = 1,
/// <summary>
/// Reduce by a specified rule
/// </summary>
Reduce = 2,
/// <summary>
/// Goto to a state on reduction
/// </summary>
Goto = 3,
/// <summary>
/// Input successfully parsed
/// </summary>
Accept = 4,
/// <summary>
/// Error
/// </summary>
Error = 5
}
}

View file

@ -1,84 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// State of LR parser.
/// </summary>
public class LRState
{
private int m_index;
private LRStateAction[] m_actions;
internal LRStateAction[] m_transitionVector;
/// <summary>
/// Creates a new instance of the <c>LRState</c> class
/// </summary>
/// <param name="index">Index of the LR state in the LR state table.</param>
/// <param name="actions">List of all available LR actions in this state.</param>
/// <param name="transitionVector">Transition vector which has symbol index as an index.</param>
public LRState(int index, LRStateAction[] actions, LRStateAction[] transitionVector)
{
m_index = index;
m_actions = actions;
m_transitionVector = transitionVector;
}
/// <summary>
/// Gets index of the LR state in LR state table.
/// </summary>
public int Index
{
get { return m_index; }
}
/// <summary>
/// Gets LR state action count.
/// </summary>
public int ActionCount
{
get { return m_actions.Length; }
}
/// <summary>
/// Returns state action by its index.
/// </summary>
/// <param name="index">State action index.</param>
/// <returns>LR state action for the given index.</returns>
public LRStateAction GetAction(int index)
{
return m_actions[index];
}
/// <summary>
/// Returns LR state action by symbol index.
/// </summary>
/// <param name="symbolIndex">Symbol Index to search for.</param>
/// <returns>LR state action object.</returns>
public LRStateAction GetActionBySymbolIndex(int symbolIndex)
{
return m_transitionVector[symbolIndex];
}
}
}

View file

@ -1,83 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// Action in a LR State.
/// </summary>
public class LRStateAction
{
private int m_index;
private Symbol m_symbol;
private LRAction m_action;
internal int m_value;
/// <summary>
/// Creats a new instance of the <c>LRStateAction</c> class.
/// </summary>
/// <param name="index">Index of the LR state action.</param>
/// <param name="symbol">Symbol associated with the action.</param>
/// <param name="action">Action type.</param>
/// <param name="value">Action value.</param>
public LRStateAction(int index, Symbol symbol, LRAction action, int value)
{
m_index = index;
m_symbol = symbol;
m_action = action;
m_value = value;
}
/// <summary>
/// Gets index of the LR state action.
/// </summary>
public int Index
{
get { return m_index; }
}
/// <summary>
/// Gets symbol associated with the LR state action.
/// </summary>
public Symbol Symbol
{
get { return m_symbol; }
}
/// <summary>
/// Gets action type.
/// </summary>
public LRAction Action
{
get { return m_action; }
}
/// <summary>
/// Gets the action value.
/// </summary>
public int Value
{
get { return m_value; }
}
}
}

View file

@ -1,448 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// Maps integer values used for transition vectors to objects.
/// </summary>
public class ObjectMap
{
#region Fields
private bool m_readonly;
private MapProvider m_mapProvider;
private const int MAXINDEX = 255;
private const int GROWTH = 32;
private const int MINSIZE = 32;
private const int MAXARRAYCOUNT = 12;
private const int INVALIDKEY = Int32.MaxValue;
#endregion
#region Constructors
/// <summary>
/// Creates new instance of <see cref="ObjectMap"/> class.
/// </summary>
public ObjectMap()
{
m_mapProvider = new SortedMapProvider(MINSIZE);
}
#endregion
#region Public members.
/// <summary>
/// Gets number of entries in the map.
/// </summary>
public int Count
{
get { return m_mapProvider.m_count; }
}
/// <summary>
/// Gets or sets read only flag.
/// </summary>
public bool ReadOnly
{
get { return m_readonly; }
set
{
if (m_readonly != value)
{
SetMapProvider(value);
m_readonly = value;
}
}
}
/// <summary>
/// Gets or sets value by key.
/// </summary>
public object this[int key]
{
get { return m_mapProvider[key]; }
set { m_mapProvider.Add(key, value); }
}
/// <summary>
/// Returns key by index.
/// </summary>
/// <param name="index">Zero based index of the requested key.</param>
/// <returns>Returns key for the given index.</returns>
public int GetKey(int index)
{
return m_mapProvider.GetEntry(index).Key;
}
/// <summary>
/// Removes entry by its key.
/// </summary>
/// <param name="key"></param>
public void Remove(int key)
{
m_mapProvider.Remove(key);
}
/// <summary>
/// Adds a new key and value pair.
/// If key exists then value is applied to existing key.
/// </summary>
/// <param name="key">New key to add.</param>
/// <param name="value">Value for the key.</param>
public void Add(int key, object value)
{
m_mapProvider.Add(key, value);
}
#endregion
#region Private members
private void SetMapProvider(bool readOnly)
{
int count = m_mapProvider.m_count;
MapProvider provider = m_mapProvider;
if (readOnly)
{
SortedMapProvider pr = m_mapProvider as SortedMapProvider;
if (pr.m_lastKey <= MAXINDEX)
{
provider = new IndexMapProvider();
}
else if (count <= MAXARRAYCOUNT)
{
provider = new ArrayMapProvider(m_mapProvider.m_count);
}
}
else
{
if (! (provider is SortedMapProvider))
{
provider = new SortedMapProvider(m_mapProvider.m_count);
}
}
if (provider != m_mapProvider)
{
for (int i = 0; i < count; i++)
{
Entry entry = m_mapProvider.GetEntry(i);
provider.Add(entry.Key, entry.Value);
}
m_mapProvider = provider;
}
}
#endregion
#region Entry struct definition
private struct Entry
{
internal int Key;
internal object Value;
internal Entry(int key, object value)
{
Key = key;
Value = value;
}
}
#endregion
private abstract class MapProvider
{
internal int m_count; // Entry count in the collection.
internal abstract object this[int key]
{
get;
}
internal abstract Entry GetEntry(int index);
internal abstract void Add(int key, object value);
internal virtual void Remove(int key)
{
throw new InvalidOperationException();
}
}
private class SortedMapProvider : MapProvider
{
internal Entry[] m_entries; // Array of entries.
internal int m_lastKey; // Bigest key number.
internal SortedMapProvider(int capacity)
{
m_entries = new Entry[capacity];
}
internal override object this[int key]
{
get
{
int minIndex = 0;
int maxIndex = m_count - 1;
if (maxIndex >= 0 && key <= m_lastKey)
{
do
{
int midIndex = (maxIndex + minIndex) / 2;
if (key <= m_entries[midIndex].Key)
{
maxIndex = midIndex;
}
else
{
minIndex = midIndex + 1;
}
} while (minIndex < maxIndex);
if (key == m_entries[minIndex].Key)
{
return m_entries[minIndex].Value;
}
}
return null;
}
}
internal override Entry GetEntry(int index)
{
return m_entries[index];
}
internal override void Add(int key, object value)
{
bool found;
int index = FindInsertIndex(key, out found);
if (found)
{
m_entries[index].Value = value;
return;
}
if (m_count >= m_entries.Length)
{
Entry[] entries = new Entry[m_entries.Length + GROWTH];
Array.Copy(m_entries, 0, entries, 0, m_entries.Length);
m_entries = entries;
}
if (index < m_count)
{
Array.Copy(m_entries, index, m_entries, index + 1, m_count - index);
}
else
{
m_lastKey = key;
}
m_entries[index].Key = key;
m_entries[index].Value = value;
m_count++;
}
internal override void Remove(int key)
{
int index = FindIndex(key);
if (index >= 0)
{
int tailSize = (m_count - 1) - index;
if (tailSize > 0)
{
Array.Copy(m_entries, index + 1, m_entries, index, tailSize);
}
else if (m_count > 1)
{
m_lastKey = m_entries[m_count - 2].Key;
}
else
{
m_lastKey = INVALIDKEY;
}
m_count--;
m_entries[m_count].Key = INVALIDKEY;
m_entries[m_count].Value = null;
}
}
private int FindIndex(int key)
{
int minIndex = 0;
if (m_count > 0 && key <= m_lastKey)
{
int maxIndex = m_count - 1;
do
{
int midIndex = (maxIndex + minIndex) / 2;
if (key <= m_entries[midIndex].Key)
{
maxIndex = midIndex;
}
else
{
minIndex = midIndex + 1;
}
} while (minIndex < maxIndex);
if (key == m_entries[minIndex].Key)
{
return minIndex;
}
}
return -1;
}
private int FindInsertIndex(int key, out bool found)
{
int minIndex = 0;
if (m_count > 0 && key <= m_lastKey)
{
int maxIndex = m_count - 1;
do
{
int midIndex = (maxIndex + minIndex) / 2;
if (key <= m_entries[midIndex].Key)
{
maxIndex = midIndex;
}
else
{
minIndex = midIndex + 1;
}
} while (minIndex < maxIndex);
found = (key == m_entries[minIndex].Key);
return minIndex;
}
found = false;
return m_count;
}
}
private class IndexMapProvider : MapProvider
{
private object[] m_array; // Array of entries.
internal IndexMapProvider()
{
m_array = new object[MAXINDEX + 1];
for (int i = m_array.Length; --i >= 0; )
{
m_array[i] = Unassigned.Value;
}
}
internal override object this[int key]
{
get
{
if (key >= m_array.Length || key < 0)
{
return null;
}
return m_array[key];
}
}
internal override Entry GetEntry(int index)
{
int idx = -1;
for (int i = 0; i < m_array.Length; i++)
{
object value = m_array[i];
if (value != Unassigned.Value)
{
idx++;
}
if (idx == index)
{
return new Entry(i, value);
}
}
return new Entry();
}
internal override void Add(int key, object value)
{
m_array[key] = value;
m_count++;
}
}
private class ArrayMapProvider : MapProvider
{
private Entry[] m_entries; // Array of entries.
internal ArrayMapProvider(int capacity)
{
m_entries = new Entry[capacity];
}
internal override object this[int key]
{
get
{
for (int i = m_count; --i >= 0;)
{
Entry entry = m_entries[i];
int entryKey = entry.Key;
if (entryKey < key)
{
continue;
}
else if (entryKey == key)
{
return entry.Value;
}
else if (entryKey > key)
{
return null;
}
}
return null;
}
}
internal override Entry GetEntry(int index)
{
return m_entries[index];
}
internal override void Add(int key, object value)
{
m_entries[m_count].Key = key;
m_entries[m_count].Value = value;
m_count++;
}
}
private class Unassigned
{
internal static Unassigned Value = new Unassigned();
}
}
}

View file

@ -1,108 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// Available parse messages.
/// </summary>
public enum ParseMessage
{
/// <summary>
/// Nothing
/// </summary>
Empty = 0,
/// <summary>
/// Each time a token is read, this message is generated.
/// </summary>
TokenRead = 1,
/// <summary>
/// When the engine is able to reduce a rule,
/// this message is returned. The rule that was
/// reduced is set in the GOLDParser's ReduceRule property.
/// The tokens that are reduced and correspond the
/// rule's definition are stored in the Tokens() property.
/// </summary>
Reduction = 2,
/// <summary>
/// The engine will returns this message when the source
/// text has been accepted as both complete and correct.
/// In other words, the source text was successfully analyzed.
/// </summary>
Accept = 3,
/// <summary>
/// Before any parsing can take place,
/// a Compiled Grammar Table file must be loaded.
/// </summary>
NotLoadedError = 4,
/// <summary>
/// The tokenizer will generate this message when
/// it is unable to recognize a series of characters
/// as a valid token. To recover, pop the invalid
/// token from the input queue.
/// </summary>
LexicalError = 5,
/// <summary>
/// Often the parser will read a token that is not expected
/// in the grammar. When this happens, the Tokens() property
/// is filled with tokens the parsing engine expected to read.
/// To recover: push one of the expected tokens on the input queue.
/// </summary>
SyntaxError = 6,
/// <summary>
/// The parser reached the end of the file while reading a comment.
/// This is caused when the source text contains a "run-away"
/// comment, or in other words, a block comment that lacks the
/// delimiter.
/// </summary>
CommentError = 7,
/// <summary>
/// Something is wrong, very wrong.
/// </summary>
InternalError = 8,
/// <summary>
/// A block comment is complete.
/// When this message is returned, the content of the CurrentComment
/// property is set to the comment text. The text includes starting and ending
/// block comment characters.
/// </summary>
CommentBlockRead = 9,
/// <summary>
/// Line comment is read.
/// When this message is returned, the content of the CurrentComment
/// property is set to the comment text. The text includes starting
/// line comment characters.
/// </summary>
CommentLineRead = 10,
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,135 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
using System.Text;
#endregion
namespace GoldParser
{
/// <summary>
/// Rule is the logical structures of the grammar.
/// </summary>
/// <remarks>
/// Rules consist of a head containing a nonterminal
/// followed by a series of both nonterminals and terminals.
/// </remarks>
public class Rule
{
private int m_index;
internal Symbol m_nonTerminal;
internal Symbol[] m_symbols;
internal bool m_hasOneNonTerminal;
internal bool m_hasEmpty;
/// <summary>
/// Creates a new instance of <c>Rule</c> class.
/// </summary>
/// <param name="index">Index of the rule in the grammar rule table.</param>
/// <param name="nonTerminal">Nonterminal of the rule.</param>
/// <param name="symbols">Terminal and nonterminal symbols of the rule.</param>
public Rule(int index, Symbol nonTerminal, Symbol[] symbols)
{
m_index = index;
m_nonTerminal = nonTerminal;
m_symbols = symbols;
m_hasOneNonTerminal = (symbols.Length == 1)
&& (symbols[0].SymbolType == SymbolType.NonTerminal);
m_hasEmpty=symbols.Length == 0;// && m_nonTerminal.Name == "empty";
}
/// <summary>
/// Gets index of the rule in the rule table.
/// </summary>
public int Index
{
get { return m_index; }
}
/// <summary>
/// Gets the head symbol of the rule.
/// </summary>
public Symbol NonTerminal
{
get { return m_nonTerminal; }
}
/// <summary>
/// Gets name of the rule.
/// </summary>
public string Name
{
get { return '<' + m_nonTerminal.Name + '>'; }
}
/// <summary>
/// Gets number of symbols.
/// </summary>
public int Count
{
get { return m_symbols.Length; }
}
/// <summary>
/// Gets symbol by its index.
/// </summary>
public Symbol this[int index]
{
get { return m_symbols[index]; }
}
/// <summary>
/// Gets true if the rule contains exactly one symbol.
/// </summary>
/// <remarks>Used by the Parser object to TrimReductions</remarks>
public bool ContainsOneNonTerminal
{
get { return m_hasOneNonTerminal; }
}
/// <summary>
/// Gets the rule definition.
/// </summary>
public string Definition
{
get
{
StringBuilder result = new StringBuilder();
for (int i = 0; i < m_symbols.Length; i++)
{
result.Append(m_symbols[i].ToString());
if (i < m_symbols.Length - 1)
result.Append(' ');
}
return result.ToString();
}
}
/// <summary>
/// Returns the Backus-Noir representation of the rule.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Name + " ::= " + Definition;
}
}
}

View file

@ -1,100 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
using System.IO;
using System.Resources;
using System.Globalization;
#endregion
namespace GoldParser
{
/// <summary>
/// Custom resource class. Usage:
/// string s = Res.GetString(Res.MyIdenfitier);
/// </summary>
internal sealed class SR
{
static SR ms_loader = new SR();
private ResourceManager m_resources;
private SR()
{
m_resources = new ResourceManager("GoldParser", this.GetType().Module.Assembly);
}
/* These function can be useful in other applications.
public static string GetString(string name, params object[] args)
{
// null CultureInfo: let ResouceManager determine the culture
return GetString(null, name, args);
}
public static string GetString(CultureInfo culture, string name, params object[] args)
{
string res = ms_loader.m_resources.GetString(name, culture);
if (args != null && args.Length > 0)
{
return String.Format(culture, res, args);
}
else
{
return res;
}
}
*/
public static string GetString(string name)
{
return GetString(null, name);
}
public static string GetString(CultureInfo culture, string name)
{
return ms_loader.m_resources.GetString(name, culture);
}
// Code below is automatically generated by GenResNm.exe.
// Do not modify it manually.
#region Resource String Names
internal const string Grammar_WrongFileHeader = "Grammar_WrongFileHeader";
internal const string Grammar_InvalidRecordType = "Grammar_InvalidRecordType";
internal const string Grammar_NoEntry = "Grammar_NoEntry";
internal const string Grammar_EmptyEntryExpected = "Grammar_EmptyEntryExpected";
internal const string Grammar_StringEntryExpected = "Grammar_StringEntryExpected";
internal const string Grammar_IntegerEntryExpected = "Grammar_IntegerEntryExpected";
internal const string Grammar_ByteEntryExpected = "Grammar_ByteEntryExpected";
internal const string Grammar_BooleanEntryExpected = "Grammar_BooleanEntryExpected";
internal const string Grammar_InvalidRecordHeader = "Grammar_InvalidRecordHeader";
#endregion
}
}

View file

@ -1,31 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// This callback is used by parser to notify read source line.
/// Use parser.LineText to get line source.
/// </summary>
public delegate void SourceLineReadCallback(Parser parser, int lineStart, int lineLength);
}

View file

@ -1,142 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
using System.Text;
#endregion
namespace GoldParser
{
/// <summary>
/// Represents a terminal or nonterminal symbol used by the Deterministic
/// Finite Automata (DFA) and LR Parser.
/// </summary>
/// <remarks>
/// Symbols can be either terminals (which represent a class of
/// tokens - such as identifiers) or nonterminals (which represent
/// the rules and structures of the grammar). Terminal symbols fall
/// into several categories for use by the GOLD Parser Engine
/// which are enumerated in <c>SymbolType</c> enumeration.
/// </remarks>
public class Symbol
{
internal int m_index; // symbol index in symbol table
private string m_name; // name of the symbol
internal SymbolType m_symbolType; // type of the symbol
private string m_text; // printable representation of symbol
private const string m_quotedChars = "|-+*?()[]{}<>!";
/// <summary>
/// Creates a new instance of <c>Symbol</c> class.
/// </summary>
/// <param name="index">Symbol index in symbol table.</param>
/// <param name="name">Name of the symbol.</param>
/// <param name="symbolType">Type of the symbol.</param>
public Symbol(int index, string name, SymbolType symbolType)
{
m_index = index;
m_name = name;
m_symbolType = symbolType;
}
/// <summary>
/// Returns the index of the symbol in the GOLDParser object's Symbol Table.
/// </summary>
public int Index
{
get { return m_index; }
}
/// <summary>
/// Returns the name of the symbol.
/// </summary>
public string Name
{
get { return m_name; }
}
/// <summary>
/// Returns an enumerated data type that denotes
/// the class of symbols that the object belongs to.
/// </summary>
public SymbolType SymbolType
{
get { return m_symbolType; }
}
/// <summary>
/// Returns the text representation of the symbol.
/// In the case of nonterminals, the name is delimited by angle brackets,
/// special terminals are delimited by parenthesis
/// and terminals are delimited by single quotes
/// (if special characters are present).
/// </summary>
/// <returns>String representation of symbol.</returns>
public override string ToString()
{
if (m_text == null)
{
switch (SymbolType)
{
case SymbolType.NonTerminal:
m_text = '<' + Name + '>';
break;
case SymbolType.Terminal:
m_text = FormatTerminalSymbol(Name);
break;
default:
m_text = '(' + Name + ')';
break;
}
}
return m_text;
}
private static string FormatTerminalSymbol(string source)
{
StringBuilder result = new StringBuilder();
for (int i = 0; i < source.Length; i++)
{
char ch = source[i];
if (ch == '\'')
{
result.Append("''");
}
else if (IsQuotedChar(ch) || (ch == '"'))
{
result.Append(new Char[] {'\'', ch, '\''});
}
else
{
result.Append(ch);
}
}
return result.ToString();
}
private static bool IsQuotedChar(char value)
{
return (m_quotedChars.IndexOf(value) >= 0);
}
}
}

View file

@ -1,81 +0,0 @@
#region Copyright
//----------------------------------------------------------------------
// Gold Parser engine.
// See more details on http://www.devincook.com/goldparser/
//
// Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
//
// This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
//
// The translation is based on the other engine translations:
// Delphi engine by Alexandre Rai (riccio@gmx.at)
// C# engine by Marcus Klimstra (klimstra@home.nl)
//----------------------------------------------------------------------
#endregion
#region Using directives
using System;
#endregion
namespace GoldParser
{
/// <summary>
/// Type of symbol.
/// </summary>
public enum SymbolType
{
/// <summary>
/// Normal nonterminal
/// </summary>
NonTerminal = 0,
/// <summary>
/// Normal terminal
/// </summary>
Terminal = 1,
/// <summary>
/// This Whitespace symbols is a special terminal
/// that is automatically ignored the the parsing engine.
/// Any text accepted as whitespace is considered
/// to be inconsequential and "meaningless".
/// </summary>
WhiteSpace = 2,
/// <summary>
/// The End symbol is generated when the tokenizer
/// reaches the end of the source text.
/// </summary>
End = 3,
/// <summary>
/// This type of symbol designates the start of a block quote.
/// </summary>
CommentStart = 4,
/// <summary>
/// This type of symbol designates the end of a block quote.
/// </summary>
CommentEnd = 5,
/// <summary>
/// When the engine reads a token that is recognized as
/// a line comment, the remaining characters on the line
/// are automatically ignored by the parser.
/// </summary>
CommentLine = 6,
/// <summary>
/// The Error symbol is a general-purpose means
/// of representing characters that were not recognized
/// by the tokenizer. In other words, when the tokenizer
/// reads a series of characters that is not accepted
/// by the DFA engine, a token of this type is created.
/// </summary>
Error = 7
}
}

View file

@ -67,22 +67,6 @@ namespace PascalABCCompiler.Errors
public class PABCNETUnexpectedToken : SyntaxError
{
private string _message;
public PABCNETUnexpectedToken(PascalABCCompiler.ParserTools.GPBParser parser)
: base("", parser.current_file_name, parser.parsertools.GetTokenSourceContext(parser.LRParser), (syntax_tree_node)parser.prev_node)
{
List<GoldParser.Symbol> Symbols = parser.parsertools.GetPrioritySymbols(parser.LRParser.GetExpectedTokens());
if (Symbols.Count == 1)
{
string OneSybmolText = "ONE_" + Symbols[0].Name.ToUpper();
string LocOneSybmolText = PascalABCSavParser.StringResources.Get(OneSybmolText);
if (LocOneSybmolText != OneSybmolText)
{
_message = string.Format(LocOneSybmolText);
return;
}
}
_message = string.Format(PascalABCSavParser.StringResources.Get("EXPECTED{0}"), PascalABCCompiler.FormatTools.ObjectsToString(parser.parsertools.SymbolsToStrings(Symbols.ToArray()), ","));
}
public PABCNETUnexpectedToken(string _file_name, string expected, SourceContext _source_context, syntax_tree_node _node)
: base("", _file_name, _source_context, _node)
{

View file

@ -24,7 +24,7 @@ Build the project and run tests.
```bash
$ git clone https://github.com/pascalabcnet/pascalabcnet
$ cd pascalabcnet
$ sudo sh _RebuildReleaseAndRunTests.sh
$ sh _RebuildReleaseAndRunTests.sh
```
## Building PascalABC.NET in MacOS
@ -32,7 +32,7 @@ Download and install Mono from official page. Install the git-client. Run the co
```bash
$ git clone https://github.com/pascalabcnet/pascalabcnet
$ cd pascalabcnet
$ sudo sh _RebuildReleaseAndRunTests.sh
$ sh _RebuildReleaseAndRunTests.sh
```
### Run the PascalABC.NET command line compiler
@ -73,7 +73,7 @@ sudo apt-get install mono-complete
```bash
$ git clone https://github.com/pascalabcnet/pascalabcnet
$ cd pascalabcnet
$ sudo sh _RebuildReleaseAndRunTests.sh
$ sh _RebuildReleaseAndRunTests.sh
```
## Сборка проекта в MacOS
@ -81,7 +81,7 @@ $ sudo sh _RebuildReleaseAndRunTests.sh
```bash
$ git clone https://github.com/pascalabcnet/pascalabcnet
$ cd pascalabcnet
$ sudo sh _RebuildReleaseAndRunTests.sh
$ sh _RebuildReleaseAndRunTests.sh
```
### Запуск

View file

@ -2,8 +2,8 @@ library PABCRtl;
uses
PABCSystem, ABCButtons, ABCHouse, ABCObjects,
ABCSprites, BFSystem, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GOLDParserEngine, GraphABC,
ABCSprites, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GraphABC,
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4TaskMakerNET, RBDMUtils,
FormsABC, Collections, Arrays, ClientServer, __RedirectIOMode, __RunMode, __RtlUtils;

View file

@ -2,8 +2,8 @@ library PABCRtl32;
uses
PABCSystem, ABCButtons, ABCHouse, ABCObjects,
ABCSprites, BFSystem, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GOLDParserEngine, GraphABC,
ABCSprites, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GraphABC,
GraphABCHelper, IniFile, PointerTools, PointRect, Robot, RobotField,
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4, PT4TaskMakerNET, RBDMUtils,
FormsABC, Collections, Arrays, ClientServer, __RedirectIOMode, __RunMode, __RtlUtils;

View file

@ -1,7 +1,7 @@
uses
PABCSystem, __RedirectIOMode, __RunMode, ABCButtons, ABCHouse, ABCObjects,
ABCSprites, BFSystem, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GOLDParserEngine, GraphABC,
ABCSprites, Colors, CRT, DMCollect, DMTaskMaker, DMZadan, Drawman,
DrawManField, Events, FilesOperations, GraphABC,
GraphABCHelper, IniFile, PointerTools, PointRect, PT4, Robot, RobotField,
RobotTaskMaker, RobotZadan, Sockets, Utils, VCL, Timers, PT4Exam, PT4TaskMakerNET, RBDMUtils,
Collections, Arrays, Core, FormsABC, MPI, ClientServer;

View file

@ -63,7 +63,6 @@
File ..\bin\Lib\ABCObjects.pcu
File ..\bin\Lib\ABCSprites.pcu
File ..\bin\Lib\Arrays.pcu
File ..\bin\Lib\BFSystem.pcu
File ..\bin\Lib\Colors.pcu
File ..\bin\Lib\CRT.pcu
File ..\bin\Lib\DMCollect.pcu
@ -74,7 +73,6 @@
File ..\bin\Lib\Events.pcu
File ..\bin\Lib\FilesOperations.pcu
File ..\bin\Lib\FormsABC.pcu
File ..\bin\Lib\GOLDParserEngine.pcu
File ..\bin\Lib\GraphABC.pcu
File ..\bin\Lib\GraphABCHelper.pcu
File ..\bin\Lib\IniFile.pcu

View file

@ -8515,13 +8515,23 @@ namespace PascalABCCompiler.TreeConverter
si_right,get_location(id_right));
return create_static_method_call(fn,get_location(id_right),tn,false);
*/
//if (!(si_right.sym_info is common_in_function_function_node))
//if (!(si_right.sym_info is common_in_function_function_node))
if (dn is compiled_function_node)
{
if ((dn as compiled_function_node).ConnectedToType == tn)
AddError(new UndefinedNameReference(id_right.name, get_location(id_right)));
}
else if (dn is common_namespace_function_node)
{
if ((dn as common_namespace_function_node).ConnectedToType == tn)
AddError(new UndefinedNameReference(id_right.name, get_location(id_right)));
}
if (dn.semantic_node_type == semantic_node_type.indefinite_definition_node)
{
return new indefinite_reference(dn as indefinite_definition_node, get_location(id_right));
}
return make_delegate_wrapper(null, si_right, get_location(id_right), true);
return make_delegate_wrapper(null, si_right, get_location(id_right), true);
}
case general_node_type.property_node:
{
@ -12165,6 +12175,8 @@ namespace PascalABCCompiler.TreeConverter
}
case proc_attribute.attr_extension:
{
if (context.converted_compiled_type != null)
AddError(get_location(_procedure_attributes_list), "EXTENSIONMETHOD_KEYWORD_NOT_ALLOWED");
if (in_interface_part)
AddError(get_location(_procedure_attributes_list), "EXTENSION_METHODS_IN_INTERFACE_PART_NOT_ALLOWED");
if (!(context.top_function is common_namespace_function_node))

View file

@ -29,8 +29,8 @@ if [ $? -eq 0 ]; then
sn -R PABCRtl32.dll KeyPair32.snk
sn -Vu PABCRtl32.dll
cp PABCRtl32.dll ../../bin/Lib
gacutil -u PABCRtl
gacutil -i ../../bin/Lib/PABCRtl.dll
sudo gacutil -u PABCRtl
sudo gacutil -i ../../bin/Lib/PABCRtl.dll
cd ..
mono ../bin/pabcnetc.exe RebuildStandartModules.pas /rebuild
if [ $? -eq 0 ]; then

View file

@ -1,79 +0,0 @@
unit BFSystem;
//BF language support
//Version 2.1
//Copyright (c) 2006-2007 DarkStar
{$apptype console}
interface
uses System, PABCSystem, CRT;
const
BufferSize = 30000;
ConsoleTextColor = Green;
InFileExt = '.in';
OutFileExt = '.out';
var
BFField := new byte[BufferSize];
BFCaretPos:integer;
BFOutFile:Text;
BFInFile:Text;
procedure WriteCaretValue; //.
procedure ReadCaretValue; //,
implementation
var ReadFromInFile:boolean;
procedure BFInit;
var fin_name: string;
begin
BFCaretPos := 0;
fin_name := ChangeFileNameExtension(GetEXEFileName, InFileExt);
ReadFromInFile := FileExists(fin_name);
if ReadFromInFile then begin
AssignFile(BFInFile, fin_name);
Reset(BFInFile);
end;
AssignFile(BFOutFile,ChangeFileNameExtension(GetEXEFileName, OutFileExt));
Rewrite(BFOutFile);
TextColor(ConsoleTextColor);
end;
procedure BFClose;
begin
CloseFile(BFInFile);
CloseFile(BFOutFile);
end;
procedure WriteCaretValue;
var c: char;
begin
c := char(BFField[BFCaretPos]);
Write(c);
Write(BFOutFile, c);
end;
procedure ReadCaretValue;
var c: char;
begin
if ReadFromInFile then begin
if EOF(BFInFile) then
BFField[BFCaretPos] := 0
else begin
Read(BFInFile, c);
BFField[BFCaretPos] := byte(c);
end;
end else
BFField[BFCaretPos] := byte(CurrentIOSystem.read_symbol);
end;
initialization
BFInit;
finalization
BFClose;
end.

File diff suppressed because it is too large Load diff

View file

@ -1,32 +0,0 @@
unit MathForKumir;
interface
function ctg(x:real):real;
function arcctg(x:real):real;
function md (x,y:integer):integer;
function dv(x,y:integer):integer;
function Power(x,y:real):real;
implementation
function ctg(x:real):real;
begin
result:=1/tan(x);
end;
function arcctg(x:real):real;
begin
result:=Pi/2-arctan(x);;
end;
function md (x,y:integer):integer;
begin
result:=x mod y;
end;
function dv(x,y:integer):integer;
begin
result:=x div y;
end;
function Power(x,y:real):real;
begin
result:=Exp(y*Ln(x));
end;
end.

View file

@ -117,7 +117,8 @@ EXPLICIT_IMPLEMENTATION_EXPECTED=Method implementation expected
ANONYMOUS_FUNCTION_TYPE_WITH_GENERICS=Anonymous delegates can not use generic parameters
CLASS_NOT_IMPLEMENT_THIS_INTERFACE=Class doesn't implement this interface
INTERFACE_EXPECTED=Interface expected
IMPLICIT_EXPLICIT_OPERATOR_EXTENSION_ONLY_FOR_COMPILED_CLASSES_ALLOWED=Operators implicit and explicit can be extended only for classes from another .NET assemblies
IMPLICIT_EXPLICIT_OPERATOR_EXTENSION_ONLY_FOR_COMPILED_CLASSES_ALLOWED=Operators implicit and explicit can be extended only for classes from another .NET assemblies
EXTENSIONMETHOD_KEYWORD_NOT_ALLOWED=extensionmethod is not allowed in this context
%PREFIX%=COMPILATIONERROR_
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Unit expected, library found
ASSEMBLY_{0}_READING_ERROR=Error by reading assembly '{0}'

View file

@ -113,6 +113,7 @@ ANONYMOUS_FUNCTION_TYPE_WITH_GENERICS=Недопустимо описание а
CLASS_NOT_IMPLEMENT_THIS_INTERFACE=Класс не реализует данный интерфейс
INTERFACE_EXPECTED=Ожидался интерфейс
IMPLICIT_EXPLICIT_OPERATOR_EXTENSION_ONLY_FOR_COMPILED_CLASSES_ALLOWED=extension-операторы преобразования типов допустимы только для классов из других сборок .NET
EXTENSIONMETHOD_KEYWORD_NOT_ALLOWED=Атрибут extensionmethod недопустим в данном контексте
%PREFIX%=COMPILATIONERROR_
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека
ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}'

Binary file not shown.

Binary file not shown.

Binary file not shown.