Code Monkey home page Code Monkey logo

ohm-s's People

Contributors

abstraktor avatar bdaase avatar codezeilen avatar fniephaus avatar marcfreiheit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ohm-s's Issues

Allow access to skipped whitespace

In order to support Pretty Printers, the CST should allow access to whitespace. The whitespace does not have to be explicitly materialized in the CST but could also be re-constructed after the fact.

Here are two suggestions:

  • CST nodes support the method skippedSpaces that returns the spaces skipped before the node was applied. There are two options how the spaces could be returned:
    • The spaces are returned as a simple string
    • The spaces are returned as a spaces node
  • CST nodes support the method childrenIncludingSpaces that returns a collection of all parsed nodes including the space nodes in between

Any thoughts from your side @Paula-Kli?

Add parameterized rules

  • Check whether there are duplicate parameter names
  • Cache newly created body in application

Unexpected difference between lexical and syntactic rule

I was using the following rules in Ohm-S:

Text {
  TextRule
    = text

  textCharacter
      = "\\\""
      | "\\\\"
      | ~"\\" ~"\"" any

  text
    = "\"" textCharacter+ "\""
}

When trying to match the input Hello World starting from text everything works as expected and the string is correctly matched. When starting from TextRule, however, the expression can not be matched.

I tried the very same setup in Ohm/JS, which was able to match with either rule as the starting rule.

Arity of some rules behaves inconsistently

The following rule yields nodes with only four children if the optional part does not match. It yields nodes with five children if it matches. We should check with Ohm/JS if this is intended or accidential behavior.

Pragma =
'<' identifier (':' Literal)? '>'

Late conversion of inline rule names to message names can cause clashes

Inline rule names do not match with the message that is sent to semantic actions. It is therefore possible to do the following:

SomeGrammar {
  RuleOne
    = "hello"
  Rule
    = "hello" "world" -- one
}

At the moment inline rule names' underscore is removed and the subsequent character capitalized when searching for methods in semantic actions. Both rules would therefore try to lookup the method RuleOne. Due to differing arities, only one of the rules can be acted upon.

This duplication of rules is not detected, since the inline rule name conforms to the Ohm/JS implementation (Rule_one) and is only later converted.

OhmSmalltalk grammar cannot be parsed by Ohm/JS

I stumbled upon this using the interactive ohm editor and confirmed it by setting up ohm/JS locally.

Error: Line 207, col 7:
  206 |     | stringLiteral
> 207 |     | ByteArrayLiteral
              ^~~~~~~~~~~~~~~~
  208 |     | symbolInArrayLiteral
Cannot apply syntactic rule ByteArrayLiteral from here (inside a lexical context)

After converting ByteArrayLiteral and LiteralArrayLiteralInLiteralArray to lexical rules, it does get accepted. I'm not sure, however, if that has an impact on the grammar's correctness.

OhmCheckStructure does not check rule name

I have the following set of rules:

integerConstant
	= decimalConstant
	| octalConstant

decimalConstant
	= nonzeroDigit digit*

octalConstant
	= "0" octalDigit*

octalDigit
	= "0".."7"

nonzeroDigit
	= "1".."9"

In a test case (subclass of OhmSyntaxTestCase) I want to make sure an integerConstant rule is parsed as the correct subrule as follows:

testGrammarParsesIntegerConstants

	startRule := #integerConstant.
	self shouldParse: '042' to: #(integerConstant (octalConstant '042'))

While this test passes as expected, I also noticed that it actually passes no matter what rule name I specify in the structure I supposedly assert against:

testGrammarParsesIntegerConstants

	startRule := #integerConstant.
	self shouldParse: '042' to: #(integerConstant (thisCanBeWhatever '042'))

It looks like the rule names are not compared on leaf levels:

"Check for a value"
(self structure size = 2 and: [self structure second isString])
ifTrue: [ ^ aNode interval contents = self structure second].
nonPrimitiveChildren := aNode children reject: [:n | n ruleName = OhmParsingExpression terminalRuleIdentifier].
"Check whether substructure can be valid at all"
((aNode ruleName = self structure first) and: [nonPrimitiveChildren size = (self structure size - 1)])
ifFalse: [^ false].

Is this correct behavior? And if so, what would be the expected way to write this kind of test?

OhmExplicitSendsSmalltalk has only OperandCascades

Matching something like self new test; test it is matched as OperandCascade with self as operand and new test and test as MessageChains. I was wondering whether that should be an UnaryCascade.

In case it shouldn't. What is an UnaryCascade and what a BinaryCascade? I can't find an example that is matched as one of those.

Fix potential infinite loop in Smalltalk grammar

Zum einen beschwert sich die aktuelle Ohm-JS Version über folgende Regel

in der Smalltalk-Grammatik:
BlockLiteral = "[" BlockArguments? ExecutableCode? "]"
mit der Nachricht:
"Nullable expression ExecutableCode is not allowed inside '?' (possible
infinite loop)"

Da ExecutableCode (via MoreExecutableCode und Statements) schon leer
sein kann, habe ich das ? entfernt und es funktioniert.
Nun weiß ich nicht, ob die Smalltalk-Implementierung mit ExecutableCode?
klar kommen würde.

BinaryCascade in latest fix

In the latest commit from 07.07.2020 binary cascades are again matched as operand cascades.

We tried matching 1 + 2 negated; negated which was in the commit from 06.07.2020 matched as binaryCascade and in the commit from 07.07.2020 it is matched as operandCascade from OhmExplicitSendsSmalltalk.

OhmSHRuleParser errors on incomplete Smalltalk method

On a fresh subclass of OhmGrammarSmalltalkProxy, when writing the class-side serializedGrammar method, the error Error: ByteString called #basicNew: with invalid argument -1 is thrown once the text editor contains the following:

serializedGrammar
^ '

The error is caused because the following code always assumes the opening single quote to be closed in the end:

grammarSource := aString copyFrom: offset + 1 to: (aString findLast: [:c | c = $']) - 1.

In terminalExpression a text instead of a string

When you compute the value for a _terminal node with memoization, the result is a text instead of a string.
Is this intended behavior?
You can see it in this screenshot:
grafik
The memoization is called in the OhmSynthesizedAttribute >> value:

FindFirst:startingAt: not understood

The Method FindFirst:startingAt: is not in the package. It is easy to implement it yourself in your local image but at first is missing.

Also your CI fails due to that ;)

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.