Giter Club home page Giter Club logo

flue's People

Contributors

metormaon avatar yossigil avatar

Stargazers

 avatar

Watchers

 avatar  avatar

flue's Issues

Background

Read paper by Gil and Tsoglin on Jamoos.

Polish Java's out of the box and dusty grammar

The Java grammar is sometimes intentionally stupid.... to make it easier to write a parser:


            StatementNoShortIf >> StatementWithoutTrailingSubstatement
                    | LabeledStatementNoShortIf
                    | IfThenElseStatementNoShortIf
                    | WhileStatementNoShortIf
                    | ForStatementNoShortIf
            ```
            
            Sounds a hack/ while the following requires refactoring:
            
                    
            ```        
            WhileStatement >> "while" & "(" & Expression & ")" & Statement

            WhileStatementNoShortIf >> "while" & "(" & Expression & ")" & StatementNoShortIf
            
            ````
            

Code generation

can do without minimization of DFSA, but please DO minimization.

Inlining

Whenever there is a cycle, use strongly connected components algorithm to choose the correct inlining.

Full inlining of rules

When it makes sense.

Symbols occurring twice: BooleanLiteral, CharacterLiteral, CompilationUnit
ConstantExpression, FloatingPointLiteral, IntegerLiteral, NullLiteral
StringLiteral, VariableAccess

Should inline:
3 AnnotationTypeBody
3 AnnotationTypeDeclaration
3 AnnotationTypeElementDeclaration
3 AnnotationTypeElementModifier
3 AnnotationTypeMemberDeclaration
3 ArrayCreationExpression
3 AssertStatement
3 AssignmentExpression
3 AssignmentOperator
3 BasicForStatement
3 BasicForStatementNoShortIf
3 BreakStatement
3 CastExpression
3 CatchFormalParameter
3 CatchType
3 ClassLiteral
3 ClassMemberDeclaration
3 ClassOrInterfaceTypeToInstantiate
3 ConstantModifier
3 ConstructorBody
3 ConstructorDeclaration
3 ConstructorDeclarator
3 ConstructorModifier
3 ContinueStatement
3 DefaultValue
3 DoStatement
3 ElementValueArrayInitializer
3 ElementValueList
3 ElementValuePairList
3 EmptyStatement
3 EnhancedForStatement
3 EnhancedForStatementNoShortIf
3 EnumBody
3 EnumBodyDeclarations
3 EnumConstantList
3 EnumConstantModifier
3 EnumDeclaration
3 ExceptionTypeList
3 ExplicitConstructorInvocation
3 ExpressionStatement
3 ExtendsInterfaces
3 FieldDeclaration
3 FieldModifier
3 FloatingPointType
3 ForStatement
3 ForStatementNoShortIf
3 IdentifierChars
3 IfThenElseStatement
3 IfThenElseStatementNoShortIf
3 IfThenStatement
3 InstanceInitializer
3 IntegralType
3 InterfaceBody
3 InterfaceMemberDeclaration
3 InterfaceMethodDeclaration
3 InterfaceMethodModifier
3 JavaLetter
3 JavaLetterOrDigit
3 LabeledStatement
3 LabeledStatementNoShortIf
3 LambdaBody
3 LambdaParameterList
3 LambdaParameters
3 LambdaParameterType
3 LeftHandSide
3 LocalVariableDeclarationStatement
3 MarkerAnnotation
3 MethodDeclaration
3 MethodModifier
3 MethodName
3 MethodReference
3 ModularCompilationUnit
3 ModuleDeclaration
3 ModuleDirective
3 NormalAnnotation
3 NormalClassDeclaration
3 NormalInterfaceDeclaration
3 OrdinaryCompilationUnit
3 PackageDeclaration
3 PackageModifier
3 RequiresModifier
3 ResourceList
3 ResourceSpecification
3 ReturnStatement
3 SimpleTypeName
3 SingleElementAnnotation
3 SingleStaticImportDeclaration
3 SingleTypeImportDeclaration
3 StaticImportOnDemandDeclaration
3 StaticInitializer
3 Superclass
3 SwitchBlockStatementGroup
3 SwitchExpression
3 SwitchStatement
3 SynchronizedStatement
3 TryStatement
3 TryWithResourcesStatement
3 TypeArgumentList
3 TypeArgumentsOrDiamond
3 TypeBound
3 TypeDeclaration
3 TypeImportOnDemandDeclaration
3 TypeParameterList
3 TypeParameterModifier
3 UnannArrayType
3 UnannInterfaceType
3 UnannReferenceType
3 UnqualifiedMethodIdentifier
3 VariableInitializerList
3 void
3 while
3 WhileStatement
3 WhileStatementNoShortIf
3 Wildcard
3 WildcardBounds
3 YieldStatement

Define rule categories:

We need to sort all rules in the Java examples to categories:

  1. Exclusive inheritance: A -> B | C | D. where B, C, and D are informational symbols, e.g., Module->Class|Union.
 interface A { }
 final class B extends A{} 
 final class C extends A{} 
 final class D extends A{}
  1. Enum: A -> B | C | D where B, C, and D are non-informational.
enum A { B, C, D }; 
  1. Data structure, with three operations:

    • Sequence, e.g., A - > B C
    class A { B b; C c; }
    
    • List, e.g., A -> B {C} D

      class A { B b; List<C> cs; D d;} 
      
    • optional, e.g., A -> B [C] D

      class A { B b; Optional<C> c; D d;} 
      

      Of course, there may be nesting, e.e.,g a list of enums, list of lists, etc.

    1. ERROR Anything else.

DFA minimization algorithm.

Specifically there is an algorithm that removes all inaccessible states. Do a a search in cs.theory.stackexchange

Rules inlining and graph algorithm

The inliing cytcles problem should is a reduction to a familiar problem. Create a directed graph from a grammar like so: If there is a rule A-< B C, then symbol A depends on symbol B,
and there is and an edge from A to B. Similarly, there is an edge from A to C. The problem is to find cycles in this graph. Or more generally, strongly connected components.

image

See this algorithm: https://en.wikipedia.org/wiki/Strongly_connected_component

Eliminate non-informational tokens.

One needs an algorithm for this. For example, in the rule:


            IfThenStatement >> "if" & "(" & Expression & ")" & Statement
            ```
            
            translates to 

class IfThenStatement { Expression Expression; Statement Statement; }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.