Parsing Expression Grammar for syntax highlighting - syntax-highlighting

First... Would it be possible to accomplish simple syntax highlighting using a PEG.
I'm only looking for it to be able to recognize and highlight basic things that are common to c style languages
Second... If there are any examples of this or something similar please let me know
Third... If I'm going about this the wrong way and there are more common and proven ways to do this then also let me know

Related

How would someone make their own programming language

So i'm trying to make my own Programming Language but don't really know how. I have looked it up but people say try using Python to make it, well i mean how do you make your own language like to use python you would have to Install it, Well to use my language you would have to install it aswell. How would someone make it also add Syntax Highlighting. I have tried making it in Lua and i'm not to Successful
I'm not able to make everything like that, and i also wanna have my own custom Syntax Highlighting but choose the colors like this
Syntax = {
log/Log/LOG = Blue; -- Print Function
bringback = Red; -- return function
}
function ByteText(...)
string.Byte(...)
end
function CustomFunctionsName(data)
Do(Data)
end
So i'm kinda successfull in this but i don't want it running of Lua i don't mind using a Lua api or c# or python api but i just want to learn how to make it customly like how did python and LOLCODE make their own languages? I wan't to make it like that LOLCODE's functions are so random and i wanna make it Customly and my own way just like them, If someone can Explain that would be amazing <3
You don't say why you'd want to write your own language when there are plenty available, but to answer your question....
Start by searching "language parsers" in your favorite search engine.
Learn about language parsing itself. If you're still interested after that (and it isn't an easy topic if you intend to write something from scratch) you should be able to figure out where to go next.
P.S.
Your first worry is only about what your language will accomplish and what grammar it will support. Stuff like syntax highlighting isn't something to worry about until after your language is written and can compile itself.

Best way to search Ruby syntax in search engine

I'd like to know what suggestions there are for Googling (or using other search engines if preferable) for Ruby syntax. I'm very new, and a substantial part of my baptism by fire comes by way of reading other people's code. Ruby in particular can be challenging this way-- it's fantastically compact and easy to read if you know how to read it, so to speak. But figuring that out can be difficult at times. It's worth it, but difficult. So, for example, let's say I encounter an expression like this:
tquery = "#{MASTER_URL}#{query_str}"
Well, apparently there's something going on with the syntax #{stuff}, but what? A variable being manipulated, it seems? If you encountered such an expression and didn't know about interpolation/substitution and have no ready access to someone to ask directly, how would you go about Googling that? That's just an example, of course, but I hope it illustrates the type of problem I'd like to address.
Also, if there are better tags to apply to this post please let me know and I will add. Thank you.
Symbolhound is pretty good for this. For example, here's the search for Ruby's #{}.
Mind, as you can see from the results, it doesn't necessarily come immediately back and tell you what the notation you searched for is named, or how it's defined, but it does return some helpful results to get you started. It's especially useful for punctuation-based syntax elements that are difficult or impossible to search for in other search engines.

Define-Syntax Arguments and Usage

I don't really understand the arguments and usage of define-syntax within Scheme. For what it's worth, I'm using Petite Chez Cheme. I've looked at a few sources:
define-syntax issue in scheme
Scheme Macro for nesting expressions
http://docs.racket-lang.org/guide/pattern-macros.html
However, they haven't given me the understanding I'm looking for. I'm looking for an explicit explanation of what's happening when the new syntax is applied. I'm particularly curious about the use of ellipses ("...") when the syntax is defined.
I managed to find a detailed document about patterns and define-syntax through a little bit more search. If anybody else is curious, here is the link:
http://www.cs.uml.edu/~giam/91.531/Textbooks/RKDybvig.pdf

Writing ontologies in DL syntax?

I just discovered OWL and Protege. Upon reading through this reference page (which I quote below), I am left wondering whether it is possible to not use the abstract OWL syntax, and rather to write in DL syntax. My background is in logic, so it sounds like it would be more fun even if I would have to translate the ontologies later (though I am sure there must be applications to do this--besides, don't reasoners use DL?).
If it is possible, what configuration of settings should I use in Protege (or other software of your suggestion) in order to do this? I suspect it's not possible, but I want to be sure, as I see no good reason for this other than the awkwardness of special symbols.
EDIT: If it is NOT possible, how exactly are DL languages used?
OWL DL is the description logic SHOIN with support of data values, data types
and datatype properties, i.e., SHOIN(D), but since OWL is based on RDF(S), the
terminology slightly differs. ... For description of OWL ontology or knowledge
base, the DL syntax can be used. There is an "abstract" LISP-like syntax
defined that is easier to write in ASCII character set.
Here's a very brief working example of the two syntax styles for the same data.
don't reasoners use DL?
Not necessarily. They use all kinds of logics, some of which are DLs, some are not.
If it is possible, what configuration of settings should I use in Protege (or other software of your suggestion) in order to do this?
I'm pretty sure there is no such pluggin for Protégé. But if you really want some fun, use a text editor and write your ontology by hand. There are many syntaxes you can use: the functional syntax, the OWL/XML syntax, the RDF/XML syntax are all normative. In addition, you can use the Manchester syntax, Turtle, N-Triples, JSON-LD, that will be future recommendations for writing RDF (and therefore OWL). Or the more exotic RDF/JSON, HDT. Or again, more "powerful" syntaxes like Notation3, TriG, TriX, NQuads. Plenty of fun!
In any case, if you would like to write in the DL syntax, you would need to use special Unicode characters or special commands like in LaTeX for instance. And the parser that deals with it would have to read those characters or commands. Not ideal if you are programming. But you can always use the DL syntax in your writings.
BTW, the current standard Web Ontology Language is OWL 2. Its DL variant (viz., OWL 2 DL) is based on the even more irresistible SROIQ.

Syntax highlighting for lex in gedit

I know i just need a file like /usr/share/gtksourceview-2.0/language-specs/javascript.lang. Where can i find a language definition like this for lex ?
You can find extra language definitions here, but it doesn't look like lex is among them. I think there may not be one yet. Here is a guide to writing your own.

Resources