mylang | A simple programming language inspired by Python | Interpreter library

 by   vvaltchev C++ Version: Current License: BSD-2-Clause

kandi X-RAY | mylang Summary

kandi X-RAY | mylang Summary

mylang is a C++ library typically used in Utilities, Interpreter applications. mylang has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

MyLang is a simple educational programming language inspired by Python, JavaScript, and C, written as a personal challenge, in a short time, mostly to have fun writing a recursive descent parser and explore the world of interpreters. Don't expect a full-blown scripting language with libraries and frameworks ready for production use. However, MyLang has a minimal set of builtins and, it could be used for practical purposes as well.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              mylang has a low active ecosystem.
              It has 13 star(s) with 3 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              mylang has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of mylang is current.

            kandi-Quality Quality

              mylang has no bugs reported.

            kandi-Security Security

              mylang has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              mylang is licensed under the BSD-2-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              mylang releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mylang
            Get all kandi verified functions for this library.

            mylang Key Features

            No Key Features are available at this moment for mylang.

            mylang Examples and Code Snippets

            No Code Snippets are available at this moment for mylang.

            Community Discussions

            QUESTION

            How to do case-insensitive query in tree-sitter
            Asked 2021-Jun-02 at 21:37

            I'm working on trying to create and use tree-sitter grammar in a language server I am implementing in order to support features like finding all references of a variable. Given the grammar I would be able to write a query to find all of the references to a variable with a specific name (ex. myVar). However, the language I am writing a language server for uses case insensitive variables (ex. myVar can be referenced as MYVAR, MyVaR, myvar, etc.).

            How would I be able to write a tree-sitter query to match a pattern where a token must case-insensitively match a particular string?

            I could write the query to not filter by the variable name and implement my own filtering of the results, but I was wondering if there was a way to handle this within the query itself rather than implementing custom filtering code.

            Example

            Here is a simplified example case to show what I mean.

            Given the following grammar, I want to query for all of the set_statements that set a new value to the variable myVar.

            ...

            ANSWER

            Answered 2021-Jun-02 at 21:37

            Change your query to match a regular expression matching all possible upper/lower combinations of an identifier, in this case myvar.

            If you change find_variable.query to use match with a regular expression for all case combinations:

            Source https://stackoverflow.com/questions/67550226

            QUESTION

            memory management in C parser generated by BNFC
            Asked 2021-Mar-14 at 12:32

            I use BNFC to generate parser bnfc -m -c ./mylang.cf. Internally, BNFC makefile calls bison to generate C parser.

            ...

            ANSWER

            Answered 2021-Mar-10 at 05:25

            These sort of questions should be answered in the documentation for the tool. But I couldn't find them there :-( I don't have a lot of experience with BNFC, either, so be cautious applying this answer.

            1. psProc calls the lexer's scan_string interface, and that interface makes a copy of the provided string. Flex likes to modify the input as it tokenises, so it can only deal with const char* inputs by copying them. So the string could have been freed immediately after the call to scan_string, but psProc parses the entire input before returning so you don't have anyway to do that. You can certainly free the string when psProc returns.

              I doubt whether this is an issue for you, but if you are planning on parsing very large in-memory strings, you might want to consider using fmemopen (at least, on Posix platforms) to open the string as a FILE*. That doesn't avoid the copy, but it does it in chunks of 8k or so, which avoids keeping two copies of the entire string during the parse.

            2. I have no idea how BNFC expects you to free parse tree nodes. (In fact, I rather suspect that it doesn't expect you to do that.) The nodes are linked with internal pointers, and it would certainly be possible to write an AST walker which free'd all the nodes recursively using a post-order traverse. But I don't see any generated code which does that. Perhaps I haven't looked hard enough.

              Calling free() on the top-level node will just free one node. The rest of the tree will then be leaked, since no other pointers to it exist.

            3. I'm pretty sure your suspicion about thread safety are correct. The global is assigned to by the reduction action for the Proc production, and then later returned by psProc. There's no locking, so if there were another parser in another thread, the global could get overwritten. The global is just a pointer to the node which is to be returned, and the node itself should be thread-safe, since it is dynamically-allocated by the parser thread. So you could probably change the declaration of the global(s) to use thread-local storage, but that would have to be done by postprocessing the generated code.

            Source https://stackoverflow.com/questions/66556702

            QUESTION

            How to load a specific language XAML file
            Asked 2020-Nov-16 at 14:54

            I am building my language system using XAML files.

            The code I have is as follows:

            es.xaml

            ...

            ANSWER

            Answered 2020-Nov-16 at 14:54

            What you are trying to do is possible by using DynamicResource like you did for TextBlock:

            Source https://stackoverflow.com/questions/64840684

            QUESTION

            When are K configuration cells type-checked?
            Asked 2020-Jun-10 at 23:03

            It is a common K idiom to define a programming language's syntax with a top-sort of well-formed programs (e.g. Pgm) and then to restrict the cell to have this sort in the configuration declaration using the special $PGM variable which is passed automatically by krun. This prevents users from executing programs with krun that are not well-formed. My question is:

            1. Are the sort of cells checked only at start-up time or after each rule evaluation?
            2. Do different cells show different behavior depending on their identity (e.g. the cell) or how they are typed (e.g. user-defined types versus builtin types)?

            Here is a partial example to show what I mean:

            ...

            ANSWER

            Answered 2020-Jun-10 at 21:43

            Each rule is sort-checked at kompile time to be sort-preserving, so it's not needed to check this at runtime. If something of the correct sort goes in, something of the correct sort comes out.

            The cell gets sort K, at least for example, in this definition: https://github.com/kframework/evm-semantics/blob/272608d70f363ed3d8d921887b98a26102a03032/evm.md#configuration

            it results in compiled.txt (found at .build/defn/java/driver-kompiled/compiled.txt) which looks like:

            Source https://stackoverflow.com/questions/62313301

            QUESTION

            variation in code generation, using ANTLR4 parse tree visitors
            Asked 2020-Mar-21 at 10:18

            I am writing transpiler (myLang -> JS) using ANTLR (javascript target with visitor).
            Focus is on target code generation part, from the parse tree.
            As in, how to deal with language source codes variations.

            To make question clearer, consider two variations below -

            source#1:
            PRINT 'hello there'

            source#2:

            ...

            ANSWER

            Answered 2020-Mar-21 at 10:18

            You're using getChild(1) to access the argument of the print statement. This will give you a TerminalNode containing either an ID or STRLIT token. You can access the token using the getSymbol() method and you can then access the token's type using the .type property. The type will be a number that you can compare against constants like MyLanguageParser.ID or MyLanaguageParser.STRLIT.

            Using getChild isn't necessarily the best way to access a node's children though. Each context class will have specific accessors for each of its children.

            Specifically the PrintContext object will have methods ID() and STRLIT(). One of them will return null, the other will return a TerminalNode object containing the given token. So you know whether it was an ID or string literal by seeing which one isn't null.

            That said, the more common solution would be to not have a union of possible kinds of arguments in the print rule, but instead allow any kind of expression as an argument to print. You can then use labelled alternatives in your expression rule to get different visitor methods for each kind of expression:

            Source https://stackoverflow.com/questions/60777041

            QUESTION

            Flutter - Dart - Reflectable package : how to: get class fields type? instantiate object from class/Type? set fields values using Reflectable
            Asked 2020-Feb-28 at 19:12

            I came to know that dart mirrors is disabled in flutter but hope that there might be some alternate way to achieve. Mirrors must not be disabled in flutter, it is an important & must have feature.

            ...

            ANSWER

            Answered 2020-Feb-02 at 00:44

            So far I am able to know field(s) type:

            Source https://stackoverflow.com/questions/59827412

            QUESTION

            How to reference an injected grammar within a custom VSCode language
            Asked 2020-Feb-25 at 20:23

            Prefacing the below. A demo project illustrating this issue can be found at: https://github.com/kirksl/so60384141

            I can reference an injected grammar within a native VSCode language

            specifying this (package.json)

            ...

            ANSWER

            Answered 2020-Feb-25 at 20:23

            You need to inject mylang-js.tmLanguage.json into source.mylang as well (injectTo only applies to the top-level scope name, see explanation here):

            Source https://stackoverflow.com/questions/60384141

            QUESTION

            Signature Help Provider is working incorrectly in custom extension
            Asked 2019-Sep-07 at 16:02

            We have written some time ago custom extension in VS Code for our internal programming language. We used as starting point built-in PHP extension. It worked fine until one moment (not sure exactly which). Signature Help Provider highlights random parameters. However, in our code, parameter index is correct. I have no idea what is wrong and how SignatureHelp class works.

            Here is screenshot how it behaves:

            And here is code for SignatureHelp (it's mostly untouched old built-in PHP code. Variable activeP contains correct index, its SignatureHelp class doing something wrong):

            ...

            ANSWER

            Answered 2019-Sep-07 at 16:02

            Your main issue is on the line with

            Source https://stackoverflow.com/questions/57808066

            QUESTION

            VS Code Extension: how to match "strings" without overwrite the color of another pattern (tmLanguage.json)
            Asked 2019-Jun-23 at 10:06

            I am writing an extension for a specific language for Visual Studio Code and I made it so far that I can set the colors for several commands.

            I have my mylang.tmLanguage.json which contains (simplified) the following:

            ...

            ANSWER

            Answered 2018-Jan-15 at 10:54

            You could simply include goto in the patterns for strings:

            Source https://stackoverflow.com/questions/48183784

            QUESTION

            Java - if-else statement returning false negatives
            Asked 2019-Jun-14 at 15:29

            As silly as it sounds,I want to build my own programming language--actually, a transpiler.

            I have been working on it but I have encountered a problem that my throwerr function is being called for a wrong argument

            I have a throwerr function which is meant to "throw an error" for the language whenever there is an error.The throwerr("Unk_args",firstword,linenum) is meant to throw an Unknown argument error whenever the firstword in a line is not in the alllowedFirstWords array.

            It is working well except that it is also being called for a whitespace.That is, it is says:

            Unknown argument at line 2 ie Unknown argument (whitespace) at line 2

            I don;t want that to happen.Please help.

            Here is my code (only the neccassary part)

            ...

            ANSWER

            Answered 2019-Jun-14 at 15:29

            I had to change file.split(";") to file.split("\\s*;\\s*")

            Source https://stackoverflow.com/questions/56600867

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install mylang

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/vvaltchev/mylang.git

          • CLI

            gh repo clone vvaltchev/mylang

          • sshUrl

            git@github.com:vvaltchev/mylang.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Interpreter Libraries

            v8

            by v8

            micropython

            by micropython

            RustPython

            by RustPython

            otto

            by robertkrimen

            sh

            by mvdan

            Try Top Libraries by vvaltchev

            tilck

            by vvaltchevC

            tfblib

            by vvaltchevC

            ihpp

            by vvaltchevC++