Skip to content

Commit

Permalink
Yacc MC для просмотра грамматик
Browse files Browse the repository at this point in the history
  • Loading branch information
miks1965 committed Jul 1, 2018
1 parent 7177fbe commit 784ff83
Show file tree
Hide file tree
Showing 80 changed files with 19,967 additions and 0 deletions.
16 changes: 16 additions & 0 deletions TestSuite/extendedProperties.pas
@@ -0,0 +1,16 @@
type
B = class
x: real;
end;
A = class
b1 := new B;
property X: real read b1.x write begin b1.x := value; Print(value); end;
end;

var a1 := new A;

begin
a1.X := 2;
a1.X.Print;
Assert(a1.X = 2);
end.
Binary file added YMC/Components/AspectCore/AspectCore.dll
Binary file not shown.
195 changes: 195 additions & 0 deletions YMC/Components/AspectCore/GPPGcopyright.rtf

Large diffs are not rendered by default.

Binary file added YMC/Components/AspectCore/ParserGenDoc.docx
Binary file not shown.
30 changes: 30 additions & 0 deletions YMC/Components/AspectCore/ParserSources/CSharp.lp
@@ -0,0 +1,30 @@
%Extension "cs"
%CaseSensitive
%Preprocessor Define="define" Undef="undef" IfDef="if" ElIf="elif" Else="else" End="endif"

Skip Begin "//"
Skip Begin "#" Preprocessor
Skip Begin "/*" End "*/"
Skip BeginEnd "'" EscapeSymbol "'"
Skip BeginEnd '\"' EscapeSymbol '\\'
Skip Begin '@\"' End '\"'

Token LetterDigits [[:IsLetterOrDigit:]_&]*
Token Sign [[:IsPunctuation:][:IsSymbol:]]

Rule tkClassNamespace : @"class" | @"namespace"
Rule @Block : "{" [Any | Block]* "}"
Rule Tk : @AnyExcept(tkClassNamespace, "{", "}", ";")

Rule Program : #ProgramNode*
Rule ProgramNode: #ClassOrNamespace
| #Field
| #Method
| #error

Rule ClassOrNamespace : @Tk* @tkClassNamespace @Tk* "{" #ProgramNode* "}"
Rule Field : @Tk* ";"
Rule Method : @Tk* Block

//�� ��� ��� ��� 20 �����
//������� � �������� ����� ��� �������, ���������� ������� � ���������� ��������
23 changes: 23 additions & 0 deletions YMC/Components/AspectCore/ParserSources/Java.lp
@@ -0,0 +1,23 @@
%CaseSensitive
%Extension "java"

Skip Begin "//"
Skip Begin "/*" End "*/"
Skip BeginEnd "'" EscapeSymbol "'"
Skip BeginEnd '\"' EscapeSymbol '\\'

Token ID [[:IsLetterOrDigit:]_]+
Token Sign [[:IsPunctuation:][:IsSymbol:]]

//TODO - field initializer: String [] Names = {"1", "2"};

Rule @Code : "{" [Any|Code]* "}"

Rule TKList : @AnyExcept("class", "{", "}", ";")*

Rule Program: #Imports* #Class+
Rule Imports: @TKList ";"
Rule Class : @TKList @"class" @ID "{" #ClassEntity* "}"
Rule ClassEntity : #Field | #Method
Rule Field : @TKList ";"
Rule Method : @TKList #Code
76 changes: 76 additions & 0 deletions YMC/Components/AspectCore/ParserSources/PascalABCNET.lp
@@ -0,0 +1,76 @@
%Extension "pas"
%CaseInsensitive

Skip Begin "//"
Skip Begin "#"
Skip Begin "{" End "}"
Skip Begin "/*" End "*/"
Skip BeginEnd "'" EscapeSymbol "'"

Token LetterDigits [[:IsLetterOrDigit:]_&]*
Token Sign [[:IsPunctuation:][:IsSymbol:]]

Rule tkCodeOpen : @"begin" | @"case" | @"try"
Rule tkClassOpen : @"class" | @"interface" | @"record"
Rule tkDefs : @"var" | @"const" | @"label"
Rule tkClassVisModifier : @"internal" | @"private" | @"protected" | @"public"
Rule tkMethod : @"procedure" | @"function" | @"constructor" | @"destructor"
Rule tkDirective : @"forward" | @"external"
Rule tkDirectiveHeader : @"virtual" | @"override" | @"reintroduce"
Rule tkInitFinal: @"initialization" | @"finalization"
Rule tkInterf: @"interface"
Rule tkImpl: @"implementation"

Rule Params : @"(" [@Any|@Params]* @")"
Rule @Block : tkCodeOpen [Any | Block]* "end"
Rule Attribute : @"[" [@Any | @Attribute]* @"]"

Rule Tk: @LetterDigits | @Sign | @Params | @"."
Rule Tk2: @LetterDigits | @Sign | @Params | @"." | @tkMethod | @"type" | @"[" |@"]"

Rule Program : List0(ProgramNode) [#Block "." | "end" "."] Any*

Rule ProgramNode: #Defs
| #Field
| #Method
| #InitFinal
| #InterfacePart
| #Attribute
| #error

Rule ClassNode : tkClassVisModifier
| "class"? #Field
| #ClassMethod
| #Attribute
| #error

Rule InterfacePart: tkInterf #InterfNode* tkImpl

Rule InterfNode: #Defs
| #Field
| #MethodHeader
| #Attribute
| #error

Rule Field : @Tk @Tk2* ";"
Rule Class : @Tk @Tk2* @tkClassOpen @Params? List0(ClassNode) "end" ";"

Rule Method: @MethodHeader #MethodBody
Rule MethodHeader: @"class"? @tkMethod @Tk* ";" @DirectiveHeader*
Rule MethodBody: Directive
| List0(MethodLocals) #Block ";"
Rule MethodLocals: #Defs
| #Method

Rule ClassMethod: @MethodHeader #ClassMethodBody
Rule ClassMethodBody: //empty
| Directive
| List0(Defs) #Block ";"
Rule Defs : [tkDefs|"type"] List1(FieldOrClass)
Rule FieldOrClass: #Field | #Class

Rule Directive: @tkDirective @Any* ";"
Rule DirectiveHeader: @tkDirectiveHeader ";"

Rule InitFinal : @tkInitFinal CodeToken*
Rule CodeToken: AnyExcept(tkInitFinal, "end", tkCodeOpen) | Block
22 changes: 22 additions & 0 deletions YMC/Components/AspectCore/ParserSources/XML.lp
@@ -0,0 +1,22 @@
%CaseSensitive
%Extension "xml" "xaml"

Skip Begin "<!--" End "-->"

Token ID [[:IsLetterOrDigit:]_]+
Token Sign [[:IsPunctuation:][:IsSymbol:]]

Rule TagStart: "<"
Rule TagEnd: ">"

Rule Program: [#XMLDecl|#DoctypeDcecl|#Tag]+

Rule XMLDecl : TagStart "?" @"xml" #Attribute* "?" TagEnd
Rule DoctypeDcecl: TagStart "!" @"DOCTYPE" #Attribute* TagEnd

Rule Tag: TagStart @ID #Attribute* TagEnd [#Tag|#Text]* CloseTag
| TagStart @ID #Attribute* "/" TagEnd
Rule CloseTag : TagStart "/" @ID TagEnd
Rule Attribute: @AnyExcept(">")+ "=" #String
Rule Text : @AnyExcept("<",">")+
Rule String : @'\"' @Any* @'\"'
28 changes: 28 additions & 0 deletions YMC/Components/AspectCore/ParserSources/Yacc.lp
@@ -0,0 +1,28 @@
%CaseSensitive
%Extension "y"

Skip Begin "//"
Skip Begin "/*" End "*/"
Skip BeginEnd "'" EscapeSymbol "'"
Skip BeginEnd '\"' EscapeSymbol '\\'

Token LetterDigit [[:IsLetterOrDigit:]_]+
Token Sign [[:IsPunctuation:][:IsSymbol:]]

Rule @Action : "{" [Any|Action]* "}" //���� ����, ������������ ��������� ��������

Rule @Program : #Section1 "%%" #Section2 "%%" #Section3 //��������� �������

Rule @Section1 : List0(S1Node) //������ 1 � �� �������
Rule S1Node : @"%{" @Any* @"%}"
| @"%" @AnyExcept("%%", "%", "{") @AnyExcept("%%", "%")*
| error

Rule @Section2 : List0(yRule) //������ 2 � �� �������
Rule yRule : @LetterDigit ":" List1(SubRule, "|") ";" //@LetterDigit ":" List1(SubRule, "|") ";"
| error
Rule SubRule : @List0(subRulePart)
Rule subRulePart : @AnyExcept("{", "|", ";")
| @Action

Rule @Section3 : Any*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 784ff83

Please sign in to comment.